-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvanceCal.py
More file actions
64 lines (55 loc) · 1.79 KB
/
AdvanceCal.py
File metadata and controls
64 lines (55 loc) · 1.79 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#python 3.8.8
#contract: zigm1315@gmail.com
import time
def calculate():
number_1 = float(input('Please enter the first number: '))
operation = input('''
Please type in the math operation you would like to complete:
+ for addition
- for subtraction
* for multiplication
/ for division
** for power
% for modulo
''')
number_2 = float(input('Please enter the second number: '))
start = time.time()
if operation == '+':
print('{} + {} = '.format(number_1, number_2))
print(number_1 + number_2)
print("time:", (time.time()-start)*1000)
loop()
elif operation == '-':
print('{} - {} = '.format(number_1, number_2))
print(number_1 - number_2)
print("time:", (time.time()-start)*1000)
loop()
elif operation == '*':
print('{} * {} = '.format(number_1, number_2))
print(number_1 * number_2)
print("time:", (time.time()-start)*1000)
loop()
elif operation == '/':
print('{} / {} = '.format(number_1, number_2))
print(number_1 / number_2)
print("time:", (time.time()-start)*1000)
loop()
elif operation == '**':
print('{} ** {} = '.format(number_1, number_2))
print(number_1**number_2)
print("time:", (time.time()-start)*1000)
loop()
elif operation == '%':
print('{} % {} = '.format(number_1, number_2))
print(number_1 % number_2)
print("time:", (time.time()-start)*1000)
loop()
else:
print('You have not typed a valid operator, please run the program again.')
def loop():
yn = str(input("do you want to calculate again?(y/n) : "))
if yn == 'y':
calculate()
else:
print("Good Bye~>:3")
calculate()