-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_13.py
More file actions
33 lines (23 loc) · 801 Bytes
/
5_13.py
File metadata and controls
33 lines (23 loc) · 801 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
"""
13. In the last chapter there was an exercise that asked you to create a multiplication game for
kids. Improve your program from that exercise to keep track of the number of right and
wrong answers. At the end of the program, print a message that varies depending on how
many questions the player got right.
"""
import random
right = 0
wrong = 0
for i in range(10):
i = i + 1
number1 = random.randint(0,10)
number2 = random.randint(0,10)
answer = eval(input ('Question ' + str(i) + ': ' + str(number1) + 'x' + str(number2) + ' = ' ) )
if(answer == number1 * number2 ):
right += 1
print('RIGHT!')
else:
wrong += 1
print('WRONG.',' The answer is ', number1 * number2)
print()
print('Number of right answers:', right)
print('Number of wrong answers:', wrong)