-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkhansole_academy.py
More file actions
35 lines (28 loc) · 906 Bytes
/
khansole_academy.py
File metadata and controls
35 lines (28 loc) · 906 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
34
35
"""
File: khansole_academy.py
-------------------------
Add your comments here.
"""
import random
MIN_RANDOM = 10
MAX_RANDOM = 99
NUM_CORRECT = 3
def main():
score = 0
while score < 3:
num1 = random.randint(MIN_RANDOM, MAX_RANDOM)
num2 = random.randint(MIN_RANDOM, MAX_RANDOM)
correct_answer = num1 + num2
print("What is " + str(num1) + " + " + str(num2) + "?")
user_answer = int(input("Your answer is: "))
if user_answer != correct_answer:
score = 0
print("Incorrect. The expected answer is " + str(correct_answer))
else:
score += 1
print("Correct! You've gotten " + str(0+score) + " correct in a row.")
print("Congratulations!You mastered addition.")
# This provided line is required at the end of a Python file
# to call the main() function.
if __name__ == '__main__':
main()