Skip to content

Commit

Permalink
Merge pull request #3851 from Trufoplus/main
Browse files Browse the repository at this point in the history
#21 - Python
  • Loading branch information
kontroldev committed May 24, 2024
2 parents 4cb7596 + 7ef553e commit d2304ed
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Roadmap/21 - CALLBACKS/python/Trufoplus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
####################### EJERCICIO ###########################################

def my_callback(callback):
print('Haciendo algo....')
task = 'Tarea terminada.'
callback(task)

def result(task):
print(task)

my_callback(result)


###############################################################################
### DIFICULTAD EXTRA
###############################################################################
from time import sleep
from random import randint

def process_order(confirmation):
print('\n\nConfirmando el pedido...')
random_time()
status = 'Plato confirmado'
confirmation(status)

sleep(1)
print('Preparando el plato...')
random_time()
ready = 'Plato listo para servir'
confirmation(ready)

sleep(1)
print('Entregando plato a la mesa...')
random_time()
delivery = 'Plato entregado'
confirmation(delivery)

def confirmation(status):
print(status)

def random_time():
random_time = randint(1, 10)
print(f'Tiempo de espera: {random_time} segundos\n')
sleep(random_time)

process_order(confirmation)

0 comments on commit d2304ed

Please sign in to comment.