-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime_Math.py
More file actions
36 lines (28 loc) · 888 Bytes
/
Time_Math.py
File metadata and controls
36 lines (28 loc) · 888 Bytes
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
import random
import time
operators = ["+","-","*"]
min_operand = 2
max_operand = 19
tota_problem = 10
def generate_problem():
left = random.randint(min_operand, max_operand)
right = random.randint(min_operand, max_operand)
operator = random.choice(operators)
exp = str(left) + " " + operator + " " + str(right)
answer = eval(exp)
return exp, answer
wrong = 0
input("Press enter to Start!")
print("----------------------------")
start_time = time.time()
for i in range(tota_problem):
exp, answer = generate_problem()
while True:
guess =input("#"+ str(i+1)+ " " + exp +" = ")
if guess == str(answer):
break
wrong +=1
end_time = time.time()
total_time = round(end_time - start_time, 2)
print("-----------------------------")
print("Nice work! You finidhed in ",total_time, " seconds! and ", wrong ,"times wrong")