Created
October 13, 2024 08:39
-
-
Save evanw-lgh/c95db1df7b650814a9c4ea438ffc40b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def introduction(): | |
print("Welcome to the Maths Quiz Adventure Game!") | |
print("In this game, you will navigate through levels and solve complex challenges to proceed.") | |
print("Let's get started!") | |
time.sleep(2) | |
def solve_challenge(question, answer): | |
try: | |
user_answer = float(input(question + "\n")) | |
return user_answer == answer | |
except ValueError: | |
return False | |
def level1(): | |
print("\nYou enter the first level. Solve the following equation:") | |
question = "What is 5 + 3?" | |
answer = 8 | |
if solve_challenge(question, answer): | |
print("Correct! Let's move to the next level.") | |
time.sleep(2) | |
else: | |
print("Incorrect. Try again.") | |
time.sleep(2) | |
level1() | |
def level2(): | |
print("\nYou enter the second level. Solve the following equation:") | |
question = "What is 10 - 4?" | |
answer = 6 | |
if solve_challenge(question, answer): | |
print("Correct! Let's move to the next level.") | |
time.sleep(2) | |
else: | |
print("Incorrect. Try again.") | |
time.sleep(2) | |
level2() | |
def level3(): | |
print("\nYou enter the third level. Solve the following equation:") | |
question = "What is 7 + 7?" | |
answer = 14 | |
if solve_challenge(question, answer): | |
print("Correct! You've completed the adventure!") | |
time.sleep(2) | |
else: | |
print("Incorrect. Try again.") | |
time.sleep(2) | |
level3() | |
def main(): | |
introduction() | |
level1() | |
level2() | |
level3() | |
print("Congratulations! You've completed the adventure and improved your math skills.") | |
time.sleep(2) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment