Created
August 24, 2021 22:58
-
-
Save Mathsmaniac/2b4b22a3bdcb5a3341d1a7075235593c to your computer and use it in GitHub Desktop.
Quits the program and tells the user what they have got right and wrong
This file contains 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
"""Component 4 of elements Quiz project - End summary | |
This component will tell the user how many questions | |
they have got right and wrong once they quit | |
Written by Nathan Smith | |
24/08/21""" | |
# These variables are just here for the purpose of the test, | |
# they will be given values in the main routine | |
right_answers = 5 | |
wrong_answers = 4 | |
quitting = 3 | |
dif = 1 | |
while True: | |
# The main routine goes here | |
# The first while loop will have the main routine in it, | |
# and the second one is just to get the input | |
while True: | |
user_input = input("Would you like to quit?\nType in the 'q' button " | |
"and press enter to quit," | |
" or just press enter to go another round: ") | |
print() | |
# Makes it run the main program again if just <enter> is put in | |
if user_input.lower() == "": | |
break | |
# Makes it exit this while loop then change a variable so that it | |
# quits the other while loop | |
elif user_input == "q": | |
quitting = 1 | |
break | |
else: | |
print("Sorry, I didn't quite understand that\n") | |
if quitting == 1: | |
break | |
print("Goodbye! This session you got {} correct, and {} incorrect" | |
". You were on {} difficulty".format(right_answers, wrong_answers, dif)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment