Skip to content

Commit f9d222c

Browse files
committed
Formateo de código existente
1 parent 146e64e commit f9d222c

27 files changed

+180
-123
lines changed

Backend/FastAPI/main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@
1111
app = FastAPI()
1212

1313
# Url local: http://127.0.0.1:8000
14+
15+
1416
@app.get("/")
1517
async def root():
1618
return "Hola FastAPI!"
1719

1820
# Url local: http://127.0.0.1:8000/url
21+
22+
1923
@app.get("/url")
2024
async def url():
21-
return { "url":"https://mouredev.com/python" }
25+
return {"url": "https://mouredev.com/python"}
2226

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

2630
# Documentación con Swagger: http://127.0.0.1:8000/docs
27-
# Documentación con Redocly: http://127.0.0.1:8000/redoc
31+
# Documentación con Redocly: http://127.0.0.1:8000/redoc

Backend/type_hints.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
my_typed_variable = 5
1818
print(my_typed_variable)
19-
print(type(my_typed_variable))
19+
print(type(my_typed_variable))

Basic/00_helloworld.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
'''
2222

2323
# Cómo consultar el tipo de dato
24-
print(type("Soy un dato str")) # Tipo 'str'
25-
print(type(5)) # Tipo 'int'
26-
print(type(1.5)) # Tipo 'float'
27-
print(type(3 + 1j)) # Tipo 'complex'
28-
print(type(True)) # Tipo 'bool'
29-
print(type(print("Mi cadena de texto"))) # Tipo 'NoneType'
24+
print(type("Soy un dato str")) # Tipo 'str'
25+
print(type(5)) # Tipo 'int'
26+
print(type(1.5)) # Tipo 'float'
27+
print(type(3 + 1j)) # Tipo 'complex'
28+
print(type(True)) # Tipo 'bool'
29+
print(type(print("Mi cadena de texto"))) # Tipo 'NoneType'

Basic/01_variables.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

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

2930
# Inputs
3031
name = input('¿Cuál es tu nombre? ')
@@ -43,4 +44,4 @@
4344
address = True
4445
address = 5
4546
address = 1.2
46-
print(type(address))
47+
print(type(address))

Basic/02_operators.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
### Operadores Comparativos ###
2727

2828
# Operaciones con enteros
29-
print(3 > 4)
29+
print(3 > 4)
3030
print(3 < 4)
3131
print(3 >= 4)
3232
print(4 <= 4)
3333
print(3 == 4)
3434
print(3 != 4)
3535

3636
# Operaciones con cadenas de texto
37-
print("Hola" > "Python")
37+
print("Hola" > "Python")
3838
print("Hola" < "Python")
39-
print("aaaa" >= "abaa") # Ordenación alfabética por ASCII
40-
print(len("aaaa") >= len("abaa")) # Cuenta caracteres
39+
print("aaaa" >= "abaa") # Ordenación alfabética por ASCII
40+
print(len("aaaa") >= len("abaa")) # Cuenta caracteres
4141
print("Hola" <= "Python")
4242
print("Hola" == "Hola")
4343
print("Hola" != "Python")
@@ -50,4 +50,4 @@
5050
print(3 < 4 and "Hola" < "Python")
5151
print(3 < 4 or "Hola" > "Python")
5252
print(3 < 4 or ("Hola" > "Python" and 4 == 4))
53-
print(not(3 > 4))
53+
print(not (3 > 4))

Basic/03_strings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
name, surname, age = "Brais", "Moure", 35
2424
print("Mi nombre es {} {} y mi edad es {}".format(name, surname, age))
25-
print("Mi nombre es %s %s y mi edad es %d" %(name, surname, age))
25+
print("Mi nombre es %s %s y mi edad es %d" % (name, surname, age))
2626
print("Mi nombre es " + name + " " + surname + " y mi edad es " + str(age))
2727
print(f"Mi nombre es {name} {surname} y mi edad es {age}")
2828

@@ -62,4 +62,4 @@
6262
print(language.lower())
6363
print(language.lower().isupper())
6464
print(language.startswith("Py"))
65-
print("Py" == "py") # No es lo mismo
65+
print("Py" == "py") # No es lo mismo

Basic/04_lists.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
print(my_other_list[-1])
2727
print(my_other_list[-4])
2828
print(my_list.count(30))
29-
#print(my_other_list[4]) IndexError
30-
#print(my_other_list[-5]) IndexError
29+
# print(my_other_list[4]) IndexError
30+
# print(my_other_list[-5]) IndexError
3131

3232
print(my_other_list.index("Brais"))
3333

Basic/05_tuples.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
print(my_tuple[0])
1919
print(my_tuple[-1])
20-
#print(my_tuple[4]) IndexError
21-
#print(my_tuple[-6]) IndexError
20+
# print(my_tuple[4]) IndexError
21+
# print(my_tuple[-6]) IndexError
2222

2323
print(my_tuple.count("Brais"))
2424
print(my_tuple.index("Moure"))
2525
print(my_tuple.index("Brais"))
2626

27-
#my_tuple[1] = 1.80 'tuple' object does not support item assignment
27+
# my_tuple[1] = 1.80 'tuple' object does not support item assignment
2828

2929
# Concatenación
3030

@@ -48,7 +48,7 @@
4848

4949
# Eliminación
5050

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

5353
del my_tuple
54-
#print(my_tuple) NameError: name 'my_tuple' is not defined
54+
# print(my_tuple) NameError: name 'my_tuple' is not defined

Basic/06_sets.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
my_other_set = {}
99

1010
print(type(my_set))
11-
print(type(my_other_set)) # Inicialmente es un diccionario
11+
print(type(my_other_set)) # Inicialmente es un diccionario
1212

13-
my_other_set = {"Brais","Moure", 35}
13+
my_other_set = {"Brais", "Moure", 35}
1414
print(type(my_other_set))
1515

1616
print(len(my_other_set))
@@ -19,9 +19,9 @@
1919

2020
my_other_set.add("MoureDev")
2121

22-
print(my_other_set) # Un set no es una estructura ordenada
22+
print(my_other_set) # Un set no es una estructura ordenada
2323

24-
my_other_set.add("MoureDev") # Un set no admite repetidos
24+
my_other_set.add("MoureDev") # Un set no admite repetidos
2525

2626
print(my_other_set)
2727

@@ -39,19 +39,19 @@
3939
print(len(my_other_set))
4040

4141
del my_other_set
42-
#print(my_other_set) NameError: name 'my_other_set' is not defined
42+
# print(my_other_set) NameError: name 'my_other_set' is not defined
4343

4444
# Transformación
4545

46-
my_set = {"Brais","Moure", 35}
46+
my_set = {"Brais", "Moure", 35}
4747
my_list = list(my_set)
4848
print(my_list)
4949
print(my_list[0])
5050

51-
my_other_set = {"Kotlin","Swift", "Python"}
51+
my_other_set = {"Kotlin", "Swift", "Python"}
5252

5353
# Otras operaciones
5454

5555
my_new_set = my_set.union(my_other_set)
5656
print(my_new_set.union(my_new_set).union(my_set).union({"JavaScript", "C#"}))
57-
print(my_new_set.difference(my_set))
57+
print(my_new_set.difference(my_set))

Basic/07_dicts.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
print(type(my_dict))
1111
print(type(my_other_dict))
1212

13-
my_other_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
13+
my_other_dict = {"Nombre": "Brais",
14+
"Apellido": "Moure", "Edad": 35, 1: "Python"}
1415

1516
my_dict = {
16-
"Nombre":"Brais",
17-
"Apellido":"Moure",
18-
"Edad":35,
19-
"Lenguajes": {"Python","Swift", "Kotlin"},
20-
1:1.77
21-
}
17+
"Nombre": "Brais",
18+
"Apellido": "Moure",
19+
"Edad": 35,
20+
"Lenguajes": {"Python", "Swift", "Kotlin"},
21+
1: 1.77
22+
}
2223

2324
print(my_other_dict)
2425
print(my_dict)
@@ -72,4 +73,4 @@
7273
print(my_new_dict.values())
7374
print(list(dict.fromkeys(list(my_new_dict.values())).keys()))
7475
print(tuple(my_new_dict))
75-
print(set(my_new_dict))
76+
print(set(my_new_dict))

Basic/08_conditionals.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
my_condition = False
88

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

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

3535
if my_string == "Mi cadena de textoooooo":
36-
print("Estas cadenas de texto coinciden")
36+
print("Estas cadenas de texto coinciden")

Basic/09_loops.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
while my_condition < 10:
1010
print(my_condition)
1111
my_condition += 2
12-
else: # Es opcional
12+
else: # Es opcional
1313
print("Mi condición es mayor o igual que 10")
1414

1515
print("La ejecución continúa")
@@ -35,12 +35,12 @@
3535
for element in my_tuple:
3636
print(element)
3737

38-
my_set = {"Brais","Moure", 35}
38+
my_set = {"Brais", "Moure", 35}
3939

4040
for element in my_set:
4141
print(element)
4242

43-
my_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
43+
my_dict = {"Nombre": "Brais", "Apellido": "Moure", "Edad": 35, 1: "Python"}
4444

4545
for element in my_dict:
4646
print(element)
@@ -57,4 +57,4 @@
5757
continue
5858
print("Se ejecuta")
5959
else:
60-
print("El bluce for para diccionario ha finalizado")
60+
print("El bluce for para diccionario ha finalizado")

Basic/10_functions.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,34 @@
44

55
# Definición
66

7-
def my_function ():
7+
def my_function():
88
print("Esto es una función")
99

10+
1011
my_function()
1112
my_function()
1213
my_function()
1314

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

16-
def sum_two_values (first_value: int, second_value):
17+
18+
def sum_two_values(first_value: int, second_value):
1719
print(first_value + second_value)
1820

21+
1922
sum_two_values(5, 7)
2023
sum_two_values(54754, 71231)
2124
sum_two_values("5", "7")
2225
sum_two_values(1.4, 5.2)
2326

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

26-
def sum_two_values_with_return (first_value, second_value):
29+
30+
def sum_two_values_with_return(first_value, second_value):
2731
my_sum = first_value + second_value
2832
return my_sum
2933

34+
3035
my_result = sum_two_values(1.4, 5.2)
3136
print(my_result)
3237

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

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

38-
def print_name (name, surname):
43+
44+
def print_name(name, surname):
3945
print(f"{name} {surname}")
4046

41-
print_name(surname = "Moure", name = "Brais")
47+
48+
print_name(surname="Moure", name="Brais")
4249

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

45-
def print_name_with_default (name, surname, alias = "Sin alias"):
52+
53+
def print_name_with_default(name, surname, alias="Sin alias"):
4654
print(f"{name} {surname} {alias}")
4755

56+
4857
print_name_with_default("Brais", "Moure")
4958
print_name_with_default("Brais", "Moure", "MoureDev")
5059

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

62+
5363
def print_upper_texts(*texts):
5464
print(type(texts))
5565
for text in texts:
5666
print(text.upper())
5767

5868

5969
print_upper_texts("Hola", "Python", "MoureDev")
60-
print_upper_texts("Hola")
70+
print_upper_texts("Hola")

Basic/11_classes.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@
55
# Definición
66

77
class MyEmptyPerson:
8-
pass # Para poder dejar la clase vacía
8+
pass # Para poder dejar la clase vacía
9+
910

1011
print(MyEmptyPerson)
1112
print(MyEmptyPerson())
1213

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

16+
1517
class Person:
16-
def __init__ (self, name, surname, alias = "Sin alias"):
17-
self.full_name = f"{name} {surname} ({alias})" # Propiedad pública
18-
self.__name = name # Propiedad privada
18+
def __init__(self, name, surname, alias="Sin alias"):
19+
self.full_name = f"{name} {surname} ({alias})" # Propiedad pública
20+
self.__name = name # Propiedad privada
1921

20-
def get_name (self):
22+
def get_name(self):
2123
return self.__name
2224

23-
def walk (self):
25+
def walk(self):
2426
print(f"{self.full_name} está caminando")
2527

28+
2629
my_person = Person("Brais", "Moure")
2730
print(my_person.full_name)
2831
print(my_person.get_name())

0 commit comments

Comments
 (0)