-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomquestionfunction.py
More file actions
61 lines (55 loc) · 1.43 KB
/
Copy pathrandomquestionfunction.py
File metadata and controls
61 lines (55 loc) · 1.43 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
import random
passescounter = 0
counter = 0
passes = 0
failures = 0
gen1 = 0
gen2 = 0
sum = 0
useranswer = 0
correction = []
correction2 = []
correction3 = []
while(counter<10):
if counter<5:
gen1 = random.randrange(1,1000)
gen2 = random.randrange(1,1000)
useranswer = int(input(f"what is the sum of {gen1} + {gen2} ? : "))
realanswer = gen1+gen2
correction.append(f"{gen1} + {gen2} = {realanswer} your input was {useranswer}")
counter+=1
if useranswer == realanswer:
passes+=1
else:
failures+=1
if counter<8:
gen1 = random.randrange(1,1000)
gen2 = random.randrange(1,1000)
useranswer = int(input(f"what is the subtraction of {gen1} - {gen2} ? : "))
realanswer2 = gen1-gen2
correction2.append(f"{gen1} - {gen2} = {realanswer2} your input was {useranswer}")
counter+=1
if useranswer == realanswer:
passes+=1
else:
failures+=1
if counter<10:
gen1 = random.randrange(1,1000)
gen2 = random.randrange(1,1000)
useranswer = int(input(f"what is the product of {gen1} X {gen2} ? : "))
realanswer3 = gen1*gen2
correction3.append(f"{gen1} * {gen2} = {realanswer3} your input was {useranswer}")
counter+=1
if useranswer == realanswer:
passes+=1
else:
failures+=1
for i in correction:
print(i)
for i in correction2:
print(i)
for i in correction3:
print(i)
print(f"the number of passes are {passes}")
print(f"the number of failures failures are {failures}")
print(f"grade = {passes} / {failures}")