Jayteepix

Untitled

Oct 18th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #Quiz the User - Version 1
  2. #Note: I don't like the indentation and the hanging ELSEs for example...
  3. # So I have posted a Version 2 using elifs
  4. #
  5. print("Geography")
  6. print ("Qu.1")
  7. print ("In Australia the Sun appears in the Northern Sky.")
  8. score = int(0)
  9. answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
  10. if answer != "Yes" and answer != "No" and answer != "Pass" :
  11. print("Invalid Option entered")
  12. print("Bye")
  13. else:
  14. if answer == "Pass":
  15. print("OK - maybe you could Google the question and come back?")
  16. print("bye")
  17. else:
  18. if answer == "Yes":
  19. print("Correct - Well Done - go on to question 2.")
  20. score = score + 1
  21. if answer == "No":
  22. print("Wrong - Sorry - go on to question 2.")
  23. #Qu 2
  24. print ("Qu.2")
  25. print ("Kenya is on the equator. ")
  26. answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
  27. if answer != "Yes" and answer != "No" and answer != "Pass" :
  28. print("Invalid Option entered")
  29. print("Bye")
  30. else:
  31. if answer == "Pass":
  32. print("OK could you Google the question and come back? ")
  33. print("Your score was ")
  34. print(str(score) + " out of 2")
  35. print("bye")
  36. else:
  37. if answer == "Yes":
  38. print("Correct - your score was ")
  39. score = score + 1
  40. if answer == "No":
  41. print("Wrong - Sorry, your score was ")
  42. print(str(score) + " out of 2")
  43. print("Bye")
  44.  
  45. VERSION 2
  46. #Quiz the User - Version 2
  47. #Using elif to reduce indentation
  48. #doesn't quite work exactly as Version 1
  49. #
  50. print("Geography")
  51. print ("Qu.1")
  52. print ("In Australia the Sun appears in the Northern Sky.")
  53. score = int(0)
  54. answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
  55. if answer != "Yes" and answer != "No" and answer != "Pass" :
  56. print("Invalid Option entered - please see the prompts")
  57. elif answer == "Pass":
  58. print("OK - maybe you could Google the question and come back?")
  59.  
  60. elif answer == "Yes":
  61. print("Correct - Well Done - go on to question 2.")
  62. score = score + 1
  63.  
  64. elif answer == "No":
  65. print("Wrong - Sorry - go on to question 2.")
  66.  
  67. print ("Qu.2")
  68. print ("Kenya is on the equator. ")
  69. answer = input("Please enter 'Yes' or 'No' or 'Pass' ")
  70. if answer != "Yes" and answer != "No" and answer != "Pass" :
  71. print("Invalid Option entered")
  72.  
  73. elif answer == "Pass":
  74. print("OK could you Google the question and come back? ")
  75. print("Your score was ")
  76.  
  77. elif answer == "Yes":
  78. print("Correct - your score was ")
  79. score = score + 1
  80.  
  81. elif answer == "No":
  82. print("Wrong - Sorry, your score was ")
  83. print(str(score) + " out of 2")
  84. print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment