-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMath_quiz.py
More file actions
78 lines (64 loc) · 2.94 KB
/
Math_quiz.py
File metadata and controls
78 lines (64 loc) · 2.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Math Quiz Program
# This program will do a simple math quizzes. The number should pick up
# randomly and then displayed in this following:
# 456
# +
# 476
# ========
# The program should allow the student to enter the answer. If the answer was
# correct, then the program will display Congrandulation you guest it.
# Otherwise, the program should display that this answer is wrong and gave
# them the correct answer.
import random
def main ():
first_num = random.randint(1, 1000)
second_num = random.randint(1, 1000)
print( '\t', first_num, '\t', first_num, '\t', first_num, '\t', first_num)
print( '\t', '+', '\t', '-', '\t', '*', '\t', '/' )
print( '\t',second_num,'\t',second_num, '\t', second_num,'\t', second_num)
print( '\t', '====', '\t', '====', '\t', '====', '\t', '====')
try:
number = int(input('\nEnter a number for summation ( + ): '))
summation = first_num + second_num
if number == summation:
print( 'Congradulation YOU Guest the summation', summation )
else:
print( 'This answer is wrong for (+) .....', number )
print( 'The correct answer is', summation )
except:
print( 'This answer is wrong for (+) .....', number )
print( 'The correct answer is', summation )
try:
number = int(input('\nEnter a number for substraction ( - ): '))
substract = first_num - second_num
if number == substract:
print( 'Congradulation YOU Guest the substraction', substract )
else:
print( 'This answer is wrong for (-).....', number )
print( 'The correct answer is', substract )
except:
print( 'This answer is wrong for (-).....', number )
print( 'The correct answer is', substract )
try:
number = int(input('\nEnter a number for multiplay ( * ): '))
multiplay = first_num * second_num
if number == multiplay:
print( 'Congradulation YOU Guest the multiplay', multiplay )
else:
print( 'This answer is wrong for (*) .....', number )
print( 'The correct answer is', multiplay )
except:
print( 'This answer is wrong for (*) .....', number )
print( 'The correct answer is', multiplay )
try:
number = int(input('\nEnter a number for divid ( / ): '))
divid = first_num / second_num
if number == divid:
print( 'Congradulation YOU Guest the divid', divid )
else:
print( 'This answer is wrong for ( / ).....', number )
print( 'The correct answer is', divid )
except:
print( 'This answer is wrong for ( / ).....', number )
print( 'The correct answer is', divid )
main()