From e2810f074102be23550297368e78b8ca19815db5 Mon Sep 17 00:00:00 2001 From: garcio929 Date: Thu, 29 Feb 2024 19:35:02 +0100 Subject: [PATCH 1/2] Prueba --- Basic/00_helloworld.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Basic/00_helloworld.py b/Basic/00_helloworld.py index d2c64317..e6b2c975 100644 --- a/Basic/00_helloworld.py +++ b/Basic/00_helloworld.py @@ -27,3 +27,6 @@ print(type(3 + 1j)) # Tipo 'complex' print(type(True)) # Tipo 'bool' print(type(print("Mi cadena de texto"))) # Tipo 'NoneType' +#Aqui añado + +#Realmente el tipo type no vale para nada, lo vas a usar para esatr seguro de que dato llega From e00ad1b98722e3ba668af40e16f9279bade70dd1 Mon Sep 17 00:00:00 2001 From: garcio929 <78019975+garcio929@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:07:03 +0100 Subject: [PATCH 2/2] Cambios v1 --- Basic/01_variables.py | 12 ++++++ Basic/03_strings.py | 90 ++++++++++++++++++++++++++++++++++++++++++- Basic/04_lists.py | 25 ++++++++++-- 3 files changed, 123 insertions(+), 4 deletions(-) diff --git a/Basic/01_variables.py b/Basic/01_variables.py index 682c3f73..b6676df3 100644 --- a/Basic/01_variables.py +++ b/Basic/01_variables.py @@ -1,5 +1,17 @@ # Clase en vídeo: https://youtu.be/Kp4Mvapo5kc?t=2938 +''' +Prestar atencion a los nombres de las variables + ya que no es igual que en java, aqui todo es en miniscula + + Estas son variables invalidaas + first-name + first@name + first$name + num-1 + 1num +''' + ### Variables ### my_string_variable = "My String variable" diff --git a/Basic/03_strings.py b/Basic/03_strings.py index aca89f8a..4713b8b3 100644 --- a/Basic/03_strings.py +++ b/Basic/03_strings.py @@ -24,7 +24,7 @@ print("Mi nombre es {} {} y mi edad es {}".format(name, surname, age)) print("Mi nombre es %s %s y mi edad es %d" % (name, surname, age)) print("Mi nombre es " + name + " " + surname + " y mi edad es " + str(age)) -print(f"Mi nombre es {name} {surname} y mi edad es {age}") +print(f"Mi nombre es {name} {surname} y mi edad es {age}")#Esta es la mejor por que vemos los datos donde van y donde los queremos poner # Desempaqueado de caracteres @@ -63,3 +63,91 @@ print(language.lower().isupper()) print(language.startswith("Py")) print("Py" == "py") # No es lo mismo + +#Concatenate the string 'Thirty', 'Days', 'Of', 'Python' to a single string, 'Thirty Days Of Python'. +string = 'Hola' +stringOtro = 'adios' + +print(string + ' ' + stringOtro) + +#Concatenate the string 'Coding', 'For' , 'All' to a single string, 'Coding For All'. +#Print the variable company using print(). +codingString = 'Coding' +forString = 'For' +allString = 'All' + +todojunto = codingString + forString + allString +print (todojunto) + +#Print the length of the company string using len() method and print(). +print (len(todojunto)) +#Change all the characters to uppercase letters using upper() method. +#Change all the characters to lowercase letters using lower() method. +print (todojunto.upper()) +print (todojunto.lower()) +#Use capitalize(), title(), swapcase() methods to format the value of the string Coding For All. +ejercicio = 'Coding For All' +print (ejercicio.capitalize()) #Te pone la primera en mayuscula +print (ejercicio.title()) +print (ejercicio.swapcase()) +#Cut(slice) out the first word of Coding For All string. +cortando = ejercicio[1:] +print(cortando) +#Check if Coding For All string contains a word Coding using the method index, find or other methods. +print(ejercicio.find('Coding')) +#Replace the word coding in the string 'Coding For All' to Python. +ejercicio = 'Python' +print(ejercicio) +#Change Python for Everyone to Python for All using the replace method or other methods. +print(ejercicio.replace('Python', 'cambiado')) +#Split the string 'Coding For All' using space as the separator (split()) +ejercicio = 'Coding For All' +print(ejercicio.split('')) +#"Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" split the string at the comma. +ejercicio = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" +print(ejercicio.split(', ')) +#What is the character at index 0 in the string Coding For All. +ejercicio = 'Coding For All' +print (ejercicio[0]) +#What is the last index of the string Coding For All. +ejercicio = 'Coding For All' +print (ejercicio[-1]) +#What character is at index 10 in "Coding For All" string. +print (ejercicio[10]) +#Use index to determine the position of the first occurrence of C in Coding For All. +print (ejercicio.index('C',0)) +#Use index to determine the position of the first occurrence of F in Coding For All. +print (ejercicio.index('F',0)) +#Use rfind to determine the position of the last occurrence of l in Coding For All People. +ejercicio = 'Coding For All People' +print (ejercicio.rfind('l')) +#Use index or find to find the position of the first occurrence of the word 'because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +ejercicio = 'You cannot end a sentence with because because because is a conjunction' +print (ejercicio.find('because')) +#Use rindex to find the position of the last occurrence of the word because in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +ejercicio = 'You cannot end a sentence with because because because is a conjunction' +print (ejercicio.rindex('because')) +#Slice out the phrase 'because because because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction' +ejercicio = 'You cannot end a sentence with because because because is a conjunction' +print(ejercicio.replace('because ', '')) +#Does ''Coding For All' start with a substring Coding? +ejercicio = 'Coding For All' +print(ejercicio.startswith('Coding')) +#Does 'Coding For All' end with a substring coding? +print(ejercicio.endswith('Coding')) +#' Coding For All ' , remove the left and right trailing spaces in the given string. +print(ejercicio [1:]) +"""Which one of the following variables return True when we use the method isidentifier(): +30DaysOfPython +thirty_days_of_python""" +ejercicio = '30DaysOfPython' +ejercicio2 = 'thirty_days_of_python' +print(ejercicio.isidentifier) +print(ejercicio2.isidentifier) +#The following list contains the names of some of python libraries: ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon']. Join the list with a hash with space string. +ejercicio = ['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon'] +resultado = ' '.join(ejercicio) +print(resultado) + + + diff --git a/Basic/04_lists.py b/Basic/04_lists.py index d6e6d58b..92dfaa57 100644 --- a/Basic/04_lists.py +++ b/Basic/04_lists.py @@ -25,12 +25,14 @@ print(my_other_list[1]) print(my_other_list[-1]) print(my_other_list[-4]) -print(my_list.count(30)) +print(my_list.count(30))#Busca dentro de la lista # print(my_other_list[4]) IndexError # print(my_other_list[-5]) IndexError + print(my_other_list.index("Brais")) +#desempaquetar age, height, name, surname = my_other_list print(name) @@ -40,7 +42,7 @@ # Concatenación print(my_list + my_other_list) -#print(my_list - my_other_list) +#print(my_list - my_other_list) obviamente no tiene sentido # Creación, inserción, actualización y eliminación @@ -66,7 +68,7 @@ print(my_pop_element) print(my_list) -del my_list[2] +del my_list[2] #Para borrarlo esto lo elimina pero no puedo trabajar con el print(my_list) # Operaciones con listas @@ -92,3 +94,20 @@ my_list = "Hola Python" print(my_list) print(type(my_list)) + +#Probando lo mio +fruits = ['banana', 'orange', 'mango', 'lemon','banana'] +my_pops_elements = list() +my_pops_elements.append(fruits.pop(1)) +my_pops_elements.append(fruits.pop(0)) +print(fruits) +print(my_pops_elements) + +#EJERCICIOS +#Declare an empty list +lista_vacia = list() +print(lista_vacia) +#Declare a list with more than 5 items +lista_vacia = list() +list = (1,2,3,4,5) +print(lista_vacia) \ No newline at end of file