-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
43 lines (32 loc) · 917 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# importing libraries
import time
import math
# decorator to calculate duration
# taken by any function.
def sam(func):
# added arguments inside the inner1,
# if function takes any arguments,
# can be added like this.
def inner1(*hah):
# storing time before function execution
begin = time.time()
func(*hah)
# storing time after function execution
end = time.time()
print("Total time taken in : ", func.__name__, end, " ", begin)
return inner1
# this can be added to any function present,
# in this case to calculate a factorial
@sam
def fact(num,name):
# sleep 2 seconds because it takes very less time
# so that you can see the actual difference
print("hello \n")
print(math.factorial(num))
@sam
def yo():
print("heyo, look into ma eyes!! boo, tsukuyomi!! :V")
yo()
print()
# calling the function.
fact(10,"sameer")