-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMathGame.py
64 lines (55 loc) · 1.5 KB
/
MathGame.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import random
import time
start=time.time()
print('There will be 2 rounds of questions and you will be timed')
flag=0
for i in range(2):
print('Round ', i+1)
if flag==0:
a=random.randint(0,99)
b=random.randint(0,99)
print('Sum ',a,' ',b,' equals')
c=int(input())
d=a+b
if(c==d):
print('Correct')
else:
print('wrong, the correct answer is ',d)
flag=1
if flag==0:
a=random.randint(1,99)
b=random.randint(1,99)
print('Difference ',a,' ',b,' equals')
c=int(input())
d=a-b
if(c==d):
print('Correct')
else:
print('wrong, the correct answer is ',d)
flag=1
if flag==0:
a=random.randint(1,19)
b=random.randint(1,19)
print('Product ',a,' ',b,' equals')
c=int(input())
d=a*b
if(c==d):
print('Correct')
else:
print('wrong, the correct answer is ',d)
flag=1
if flag==0:
a=random.randint(1,99)
b=random.randint(1,9)
print('Division ',a,' ',b,'to one decimal place equals')
c=float(input())
d=a/b
if(int(c*10)==int(d*10)):
print('Correct')
else:
print('wrong, the correct answer is ',d)
flag=1
if flag==0:
stop=time.time()
timeelapsed=stop-start
print('Your time is ',timeelapsed)