-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_game.py
More file actions
43 lines (31 loc) · 1.23 KB
/
math_game.py
File metadata and controls
43 lines (31 loc) · 1.23 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
class MathGame:
def __init__(self, name):
self.name = name
self.score = 0
def play(self):
print("Welcome", self.name)
print("Welcome to the Player Progress Game!")
print("In this game, the player advances through different levels and completes tasks.")
print("Each correct task adds points to your score.")
print("At the end of the game, your total score will be displayed.")
print("Good luck!\n")
useranswer = input("What is 3 + 2? ")
if useranswer == "5" or useranswer.lower() == "five":
self.score += 10
print("Correct! +10 points")
else:
print("Wrong answer")
number = int(input("Enter a number greater than 10: "))
if number > 10:
self.score += 10
print("Good job! +10 points")
else:
print("Too small")
userguess = input("Calculate 10/5 = : ")
if userguess == "2" or userguess.lower() == "two":
self.score += 20
print("Amazing! +20 points")
else:
print("Wrong! The answer was 2")
print("Game over")
print(f"Final score: {self.score}")