Skip to content

Commit 7baefc7

Browse files
committed
Hacking The Future
1 parent 5c6a53f commit 7baefc7

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

Desarrollo/08_FuncionesAnidadas.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def funcion_mayor():
2+
print("Esta es una función mayor y su mensaje de salida.")
3+
4+
def librerias():
5+
print("Algunas librerías de Python son: Scikit-learn, NumPy y TensorFlow.")
6+
7+
def frameworks():
8+
print("Algunos frameworks de Python son: Django, Dash y Flask.")
9+
10+
frameworks()
11+
librerias()
12+
13+
if __name__ == '__main__':
14+
funcion_mayor()

Desarrollo/09_Decoradores.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def decoradora(funcion):
2+
def wrapper():
3+
print("Este es el último mensaje...")
4+
funcion()
5+
print("Este es el primer mensaje ;)")
6+
return wrapper
7+
8+
@decoradora
9+
def zumbido():
10+
print("Buzzzzzz")
11+
12+
zumbido()

Desarrollo/10_NoDecoradores.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def funcion_decoradora(funcion):
2+
def wrapper():
3+
print("Este es el último mensaje...")
4+
funcion()
5+
print("Este es el primer mensaje ;)")
6+
return wrapper
7+
8+
def zumbido():
9+
print("Buzzzzzz")
10+
11+
zumbido = funcion_decoradora(zumbido)
12+
zumbido()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Millas:
2+
def __init__(self, distancia = 0):
3+
self.distancia = distancia
4+
5+
def convertir_a_kilometros(self):
6+
return (self.distancia * 1.609344)
7+
8+
9+
if __name__ == '__main__':
10+
avion = Millas()
11+
avion.distancia = int(input('¿Cuantas millas vas a viajar? '))
12+
13+
print('Tus '+str(avion.distancia)+' millas equivalen a:')
14+
print(str(avion.convertir_a_kilometros())+' Kilometros.')

0 commit comments

Comments
 (0)