Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- highscore = 0 # initalising the high score
- while True: # keep going till false (an infinite loop)
- score = 0 # initalising the score for each loop of the while loop
- print("Welcome to the math quiz") # play the game instructions
- print("Can you answer 3 questions??")
- #Q1
- print("\nQ1. What is the product of 2 x 2 x 2 ? >>")
- answer = int(input("Your answer>> ")) # get the answer and turn it inot an integer and save it tovariable answer
- # Q1 checking
- if answer == 8: ### what about adding in error trapping
- print("yay, well done, correct")
- score +=1 # increase score by one (same as score = score +1)
- print(f"your score is {score}") # other ways of printing our
- else:
- print("sorry thats not correct :(")
- print("your score ", score)
- #high score beaten??
- if score > highscore:
- highscore = score
- print(f"The current high score is>> {highscore}")
- # Q2
- print("\nQ2. What is the 4 MOD 2 ? (4%2) >>")
- answer = int(input("Your answer>> ")) # get the answer and turn it inot an integer and save it tovariable answer
- # Q2 checking
- if answer == 0: ### what about adding in error trapping
- print("yay, well done, splendido")
- score +=1 # increase score by one (same as score = score +1)
- print(f"your score is {score}") # other ways of printing our
- else:
- print("sorry thats not correct :(")
- print("your score ", score)
- #high score beaten??
- if score > highscore:
- highscore = score
- print(f"The current high score is>> {highscore}")
- # Q3
- print("\nQ3. What is 7//3 ? >>")
- answer = int(input("Your answer>> ")) # get the answer and turn it inot an integer and save it tovariable answer
- # Q3 checking
- if answer == 1: ### what about adding in error trapping
- print("yay, well done, yabadabadoo")
- score +=1 # increase score by one (same as score = score +1)
- print(f"your score is {score}") # other ways of printing our
- else:
- print("sorry thats not correct :(")
- print("your score ", score)
- #high score beaten??
- if score > highscore:
- highscore = score
- print(f"The current high score is>> {highscore}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement