Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Quiz the User - Version 1
- #Note: I don't like the indentation and the hanging ELSEs for example...
- # So I have posted a Version 2 using elifs
- #
- print("Geography")
- print ("Qu.1")
- print ("In Australia the Sun appears in the Northern Sky.")
- score = int(0)
- answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
- if answer != "Yes" and answer != "No" and answer != "Pass" :
- print("Invalid Option entered")
- print("Bye")
- else:
- if answer == "Pass":
- print("OK - maybe you could Google the question and come back?")
- print("bye")
- else:
- if answer == "Yes":
- print("Correct - Well Done - go on to question 2.")
- score = score + 1
- if answer == "No":
- print("Wrong - Sorry - go on to question 2.")
- #Qu 2
- print ("Qu.2")
- print ("Kenya is on the equator. ")
- answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
- if answer != "Yes" and answer != "No" and answer != "Pass" :
- print("Invalid Option entered")
- print("Bye")
- else:
- if answer == "Pass":
- print("OK could you Google the question and come back? ")
- print("Your score was ")
- print(str(score) + " out of 2")
- print("bye")
- else:
- if answer == "Yes":
- print("Correct - your score was ")
- score = score + 1
- if answer == "No":
- print("Wrong - Sorry, your score was ")
- print(str(score) + " out of 2")
- print("Bye")
- VERSION 2
- #Quiz the User - Version 2
- #Using elif to reduce indentation
- #doesn't quite work exactly as Version 1
- #
- print("Geography")
- print ("Qu.1")
- print ("In Australia the Sun appears in the Northern Sky.")
- score = int(0)
- answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
- if answer != "Yes" and answer != "No" and answer != "Pass" :
- print("Invalid Option entered - please see the prompts")
- elif answer == "Pass":
- print("OK - maybe you could Google the question and come back?")
- elif answer == "Yes":
- print("Correct - Well Done - go on to question 2.")
- score = score + 1
- elif answer == "No":
- print("Wrong - Sorry - go on to question 2.")
- print ("Qu.2")
- print ("Kenya is on the equator. ")
- answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
- if answer != "Yes" and answer != "No" and answer != "Pass" :
- print("Invalid Option entered")
- elif answer == "Pass":
- print("OK could you Google the question and come back? ")
- print("Your score was ")
- elif answer == "Yes":
- print("Correct - your score was ")
- score = score + 1
- elif answer == "No":
- print("Wrong - Sorry, your score was ")
- print(str(score) + " out of 2")
- print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment