This repository has been archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiplication.py
66 lines (59 loc) · 1.94 KB
/
multiplication.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
65
66
import math
from random import randint
import time
print('------------------------')
print('Multiplcation Practice!')
print('For Annie from Uncle Gaelen')
print('-----------------------')
def execute_game():
numq = input('How many questions do you want to do? (Type in how many and press enter)')
try:
int(numq)
except:
print('Enter a number please!')
execute_game()
N1 = [randint(0,10) for n in range(0,int(numq))]
N2 = [randint(0,10) for n in range(0,int(numq))]
start = input('Ok! Press Enter to start!')
stime = time.time()
corr_count = 0
for i in range(0,int(numq)):
a = input(str(N1[i]) +' X ' + str(N2[i])+ ' = ')
try:
if int(a) == N1[i]*N2[i]:
print('Correct!')
corr_count = corr_count + 1
else:
print('Incorrect! The correct answer is '+ str(N1[i]*N2[i]))
except:
print('Incorrect! The correct answer is '+ str(N1[i]*N2[i]))
etime = time.time()
print('Game Complete!')
print('You got ' + str(corr_count)+ ' correct out of '+str(numq)+'!')
grade = float(corr_count)/float(numq)
if grade > 0.9:
print('Your grade: A+! :-D')
elif grade >0.8:
print('Your grade: A! :-D')
elif grade >0.7:
print('Your grade: B! :-)')
elif grade >0.6:
print('Your grade: C! :-/')
elif grade >0.5:
print('Your grade: D! :-(')
else:
print('Your grade: F! :-(')
print('Your time was ' + str(int(etime-stime))+ ' seconds!')
rate = (etime-stime)/float(numq)
if rate > 6:
print('You could be faster!')
if rate < 3:
print('You are sooooo fast!')
else:
print('You are pretty fast!')
rep = input('Do you want to play again? Type y or n and press enter')
if rep == 'y':
execute_game()
else:
return
execute_game()