Skip to content

Commit 9df58e1

Browse files
author
raulG91
committed
mouredev#21 - Python
1 parent 486324c commit 9df58e1

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import time
2+
from random import randrange
3+
#Callbacks
4+
5+
def sum_callback(a,b):
6+
return a+b
7+
8+
def main(function_callback):
9+
print("Doing main function")
10+
result = function_callback
11+
print(f'Return of the callback {result}')
12+
13+
main(sum_callback(2,3))
14+
15+
#Extra
16+
17+
def confirm_order(order:str):
18+
print(f'Order {order} has been confirmed')
19+
20+
def orden_ready(order:str):
21+
print(f'Order {order} is ready')
22+
23+
def order_deliver(order:str):
24+
print(f'Order {order} has been delivered')
25+
26+
def process_order(order_name,callback_confirmation,callback_ready,callback_deliver):
27+
callback_confirmation(order_name)
28+
random = randrange(0,10)
29+
time.sleep(random)
30+
callback_ready(order_name)
31+
random = randrange(0,10)
32+
time.sleep(random)
33+
callback_deliver(order_name )
34+
35+
36+
37+
38+
process_order("Pizza",confirm_order,orden_ready,order_deliver)

0 commit comments

Comments
 (0)