-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTImeMath.py
41 lines (28 loc) · 974 Bytes
/
TImeMath.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
import random
import time
operators = ["+", "-", "*"]
start = 3
end = 12
def Problem_Generator():
right = random.randint(start,end)
left = random.randint(start,end)
operator = random.choice(operators)
exp = str(right) + " " + operator + " " + str(left)
answer = eval(exp)
exp += " = "
return exp, answer
print("This program test your speed at math calculations")
input("Press Enter to start the test")
print("-------------------------------------------------------------")
start_time = time.time()
for i in range(10):
exp, answer = Problem_Generator()
while True:
ans = int(input("#Problem"+str(i+1)+" "+exp))
if ans == answer:
break
print(answer)
end_time = time.time()
total_time = end_time - start_time
print("-------------------------------------------------------------")
print("You have completed the test in ",round(total_time,2),"seconds")