-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3851 from Trufoplus/main
#21 - Python
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |