The Wayback Machine - https://web.archive.org/web/20240905201920/https://github.com/mouredev/Hello-Python/commit/f9d222cad995deae42dd26a3e1ece2c773a7d475
Skip to content

Commit

Permalink
Formateo de código existente
Browse files Browse the repository at this point in the history
  • Loading branch information
mouredev committed Dec 1, 2022
1 parent 146e64e commit f9d222c
Show file tree
Hide file tree
Showing 27 changed files with 180 additions and 123 deletions.
8 changes: 6 additions & 2 deletions Backend/FastAPI/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@
app = FastAPI()

# Url local: http://127.0.0.1:8000


@app.get("/")
async def root():
return "Hola FastAPI!"

# Url local: http://127.0.0.1:8000/url


@app.get("/url")
async def url():
return { "url":"https://mouredev.com/python" }
return {"url": "https://mouredev.com/python"}

# Inicia el server: uvicorn main:app --reload
# Detener el server: CTRL+C

# Documentación con Swagger: http://127.0.0.1:8000/docs
# Documentación con Redocly: http://127.0.0.1:8000/redoc
# Documentación con Redocly: http://127.0.0.1:8000/redoc
2 changes: 1 addition & 1 deletion Backend/type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

my_typed_variable = 5
print(my_typed_variable)
print(type(my_typed_variable))
print(type(my_typed_variable))
12 changes: 6 additions & 6 deletions Basic/00_helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
'''

This comment has been minimized.

Copy link
@bustossfranco

bustossfranco Jun 8, 2024

print(("soy buenisimo"))

# Cómo consultar el tipo de dato
print(type("Soy un dato str")) # Tipo 'str'
print(type(5)) # Tipo 'int'
print(type(1.5)) # Tipo 'float'
print(type(3 + 1j)) # Tipo 'complex'
print(type(True)) # Tipo 'bool'
print(type(print("Mi cadena de texto"))) # Tipo 'NoneType'
print(type("Soy un dato str")) # Tipo 'str'
print(type(5)) # Tipo 'int'
print(type(1.5)) # Tipo 'float'
print(type(3 + 1j)) # Tipo 'complex'
print(type(True)) # Tipo 'bool'
print(type(print("Mi cadena de texto"))) # Tipo 'NoneType'
5 changes: 3 additions & 2 deletions Basic/01_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

# Variables en una sola línea. ¡Cuidado con abusar de esta sintaxis!
name, surname, alias, age = "Brais", "Moure", 'MoureDev', 35
print("Me llamo:", name, surname, ". Mi edad es:", age, ". Y mi alias es:", alias)
print("Me llamo:", name, surname, ". Mi edad es:",
age, ". Y mi alias es:", alias)

# Inputs
name = input('¿Cuál es tu nombre? ')
Expand All @@ -43,4 +44,4 @@
address = True
address = 5
address = 1.2
print(type(address))
print(type(address))
10 changes: 5 additions & 5 deletions Basic/02_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
### Operadores Comparativos ###

# Operaciones con enteros
print(3 > 4)
print(3 > 4)
print(3 < 4)
print(3 >= 4)
print(4 <= 4)
print(3 == 4)
print(3 != 4)

# Operaciones con cadenas de texto
print("Hola" > "Python")
print("Hola" > "Python")
print("Hola" < "Python")
print("aaaa" >= "abaa") # Ordenación alfabética por ASCII
print(len("aaaa") >= len("abaa")) # Cuenta caracteres
print("aaaa" >= "abaa") # Ordenación alfabética por ASCII
print(len("aaaa") >= len("abaa")) # Cuenta caracteres
print("Hola" <= "Python")
print("Hola" == "Hola")
print("Hola" != "Python")
Expand All @@ -50,4 +50,4 @@
print(3 < 4 and "Hola" < "Python")
print(3 < 4 or "Hola" > "Python")
print(3 < 4 or ("Hola" > "Python" and 4 == 4))
print(not(3 > 4))
print(not (3 > 4))
4 changes: 2 additions & 2 deletions Basic/03_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

name, surname, age = "Brais", "Moure", 35
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 %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}")

Expand Down Expand Up @@ -62,4 +62,4 @@
print(language.lower())
print(language.lower().isupper())
print(language.startswith("Py"))
print("Py" == "py") # No es lo mismo
print("Py" == "py") # No es lo mismo
4 changes: 2 additions & 2 deletions Basic/04_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
print(my_other_list[-1])
print(my_other_list[-4])
print(my_list.count(30))
#print(my_other_list[4]) IndexError
#print(my_other_list[-5]) IndexError
# print(my_other_list[4]) IndexError
# print(my_other_list[-5]) IndexError

print(my_other_list.index("Brais"))

Expand Down
10 changes: 5 additions & 5 deletions Basic/05_tuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

print(my_tuple[0])
print(my_tuple[-1])
#print(my_tuple[4]) IndexError
#print(my_tuple[-6]) IndexError
# print(my_tuple[4]) IndexError
# print(my_tuple[-6]) IndexError

print(my_tuple.count("Brais"))
print(my_tuple.index("Moure"))
print(my_tuple.index("Brais"))

#my_tuple[1] = 1.80 'tuple' object does not support item assignment
# my_tuple[1] = 1.80 'tuple' object does not support item assignment

# Concatenación

Expand All @@ -48,7 +48,7 @@

# Eliminación

#del my_tuple[2] TypeError: 'tuple' object doesn't support item deletion
# del my_tuple[2] TypeError: 'tuple' object doesn't support item deletion

del my_tuple
#print(my_tuple) NameError: name 'my_tuple' is not defined
# print(my_tuple) NameError: name 'my_tuple' is not defined
16 changes: 8 additions & 8 deletions Basic/06_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
my_other_set = {}

print(type(my_set))
print(type(my_other_set)) # Inicialmente es un diccionario
print(type(my_other_set)) # Inicialmente es un diccionario

my_other_set = {"Brais","Moure", 35}
my_other_set = {"Brais", "Moure", 35}
print(type(my_other_set))

print(len(my_other_set))
Expand All @@ -19,9 +19,9 @@

my_other_set.add("MoureDev")

print(my_other_set) # Un set no es una estructura ordenada
print(my_other_set) # Un set no es una estructura ordenada

my_other_set.add("MoureDev") # Un set no admite repetidos
my_other_set.add("MoureDev") # Un set no admite repetidos

print(my_other_set)

Expand All @@ -39,19 +39,19 @@
print(len(my_other_set))

del my_other_set
#print(my_other_set) NameError: name 'my_other_set' is not defined
# print(my_other_set) NameError: name 'my_other_set' is not defined

# Transformación

my_set = {"Brais","Moure", 35}
my_set = {"Brais", "Moure", 35}
my_list = list(my_set)
print(my_list)
print(my_list[0])

my_other_set = {"Kotlin","Swift", "Python"}
my_other_set = {"Kotlin", "Swift", "Python"}

# Otras operaciones

my_new_set = my_set.union(my_other_set)
print(my_new_set.union(my_new_set).union(my_set).union({"JavaScript", "C#"}))
print(my_new_set.difference(my_set))
print(my_new_set.difference(my_set))
17 changes: 9 additions & 8 deletions Basic/07_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
print(type(my_dict))
print(type(my_other_dict))

my_other_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
my_other_dict = {"Nombre": "Brais",
"Apellido": "Moure", "Edad": 35, 1: "Python"}

my_dict = {
"Nombre":"Brais",
"Apellido":"Moure",
"Edad":35,
"Lenguajes": {"Python","Swift", "Kotlin"},
1:1.77
}
"Nombre": "Brais",
"Apellido": "Moure",
"Edad": 35,
"Lenguajes": {"Python", "Swift", "Kotlin"},
1: 1.77
}

print(my_other_dict)
print(my_dict)
Expand Down Expand Up @@ -72,4 +73,4 @@
print(my_new_dict.values())
print(list(dict.fromkeys(list(my_new_dict.values())).keys()))
print(tuple(my_new_dict))
print(set(my_new_dict))
print(set(my_new_dict))
4 changes: 2 additions & 2 deletions Basic/08_conditionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

my_condition = False

if my_condition: # Es lo mismo que if my_condition == True:
if my_condition: # Es lo mismo que if my_condition == True:
print("Se ejecuta la condición del if")

my_condition = 5 * 5
Expand All @@ -33,4 +33,4 @@
print("Mi cadena de texto es vacía")

if my_string == "Mi cadena de textoooooo":
print("Estas cadenas de texto coinciden")
print("Estas cadenas de texto coinciden")
8 changes: 4 additions & 4 deletions Basic/09_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
while my_condition < 10:
print(my_condition)
my_condition += 2
else: # Es opcional
else: # Es opcional
print("Mi condición es mayor o igual que 10")

print("La ejecución continúa")
Expand All @@ -35,12 +35,12 @@
for element in my_tuple:
print(element)

my_set = {"Brais","Moure", 35}
my_set = {"Brais", "Moure", 35}

for element in my_set:
print(element)

my_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
my_dict = {"Nombre": "Brais", "Apellido": "Moure", "Edad": 35, 1: "Python"}

for element in my_dict:
print(element)
Expand All @@ -57,4 +57,4 @@
continue
print("Se ejecuta")
else:
print("El bluce for para diccionario ha finalizado")
print("El bluce for para diccionario ha finalizado")
24 changes: 17 additions & 7 deletions Basic/10_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,34 @@

# Definición

def my_function ():
def my_function():
print("Esto es una función")


my_function()
my_function()
my_function()

# Función con parámetros de entrada/argumentos

def sum_two_values (first_value: int, second_value):

def sum_two_values(first_value: int, second_value):
print(first_value + second_value)


sum_two_values(5, 7)
sum_two_values(54754, 71231)
sum_two_values("5", "7")
sum_two_values(1.4, 5.2)

# Función con parámetros de entrada/argumentos y retorno

def sum_two_values_with_return (first_value, second_value):

def sum_two_values_with_return(first_value, second_value):
my_sum = first_value + second_value
return my_sum


my_result = sum_two_values(1.4, 5.2)
print(my_result)

Expand All @@ -35,26 +40,31 @@ def sum_two_values_with_return (first_value, second_value):

# Función con parámetros de entrada/argumentos por clave

def print_name (name, surname):

def print_name(name, surname):
print(f"{name} {surname}")

print_name(surname = "Moure", name = "Brais")

print_name(surname="Moure", name="Brais")

# Función con parámetros de entrada/argumentos por defecto

def print_name_with_default (name, surname, alias = "Sin alias"):

def print_name_with_default(name, surname, alias="Sin alias"):
print(f"{name} {surname} {alias}")


print_name_with_default("Brais", "Moure")
print_name_with_default("Brais", "Moure", "MoureDev")

# Función con parámetros de entrada/argumentos arbitrarios


def print_upper_texts(*texts):
print(type(texts))
for text in texts:
print(text.upper())


print_upper_texts("Hola", "Python", "MoureDev")
print_upper_texts("Hola")
print_upper_texts("Hola")
15 changes: 9 additions & 6 deletions Basic/11_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
# Definición

class MyEmptyPerson:
pass # Para poder dejar la clase vacía
pass # Para poder dejar la clase vacía


print(MyEmptyPerson)
print(MyEmptyPerson())

# Clase con constructor, funciones y popiedades privadas y públicas


class Person:
def __init__ (self, name, surname, alias = "Sin alias"):
self.full_name = f"{name} {surname} ({alias})" # Propiedad pública
self.__name = name # Propiedad privada
def __init__(self, name, surname, alias="Sin alias"):
self.full_name = f"{name} {surname} ({alias})" # Propiedad pública
self.__name = name # Propiedad privada

def get_name (self):
def get_name(self):
return self.__name

def walk (self):
def walk(self):
print(f"{self.full_name} está caminando")


my_person = Person("Brais", "Moure")
print(my_person.full_name)
print(my_person.get_name())
Expand Down
Loading

0 comments on commit f9d222c

Please sign in to comment.