c0d3dsk1lls

PYTHON QUIZ! CodedSkills.net

Jul 30th, 2022 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.58 KB | None | 0 0
  1. #=========================CodedSkills.net / 1337Tutorials.net==============================
  2. #QUIZ
  3. # #-------------------------------------------------------------------------
  4.  
  5. def new_game():
  6.     guesses = []
  7.     correct_guesses = 0
  8.     question_num = 1
  9. #-------------------------------------------------------------------------
  10.  
  11.     for key in questions:
  12.         print("---------------------")
  13.         print(key)
  14.         for i in options[question_num-1]:
  15.             print(i)
  16.         guess = input("Enter (A, B, C, D): ")
  17.         guess = guess.upper()
  18.         guesses.append(guess)
  19.         correct_guesses += check_answer(questions.get(key),guess)
  20.         question_num += 1
  21.     display_score(correct_guesses, guesses)
  22. # #-------------------------------------------------------------------------
  23. def check_answer(answer, guess):
  24.     if answer == guess:
  25.         print("CORRECT!")
  26.         return 1
  27.     else:
  28.         print("WRONG!")
  29.         return 0
  30. # #-------------------------------------------------------------------------
  31. def display_score(correct_guesses, guesses):
  32.     print("--------------------------")
  33.     print("RESULTS")
  34.     print("--------------------------")
  35. #-------------------------------------------------------------------------
  36.     print("Answers: ", end="")
  37.     for i in questions:
  38.         print(questions.get(i), end=" ")
  39.     print()
  40. #-------------------------------------------------------------------------
  41.     print("Guesses: ", end="")
  42.     for i in guesses:
  43.         print(i, end=" ")
  44.     print()
  45. #-------------------------------------------------------------------------
  46.     score = ((correct_guesses/len(questions))*100)
  47.     print("Your score is: "+str(score)+"%")
  48. # #-------------------------------------------------------------------------
  49. def play_again():
  50.     response = input("Do you want to play again? (yes or no): ")
  51.     response = response.upper()
  52.     if response == "YES":
  53.         return True
  54.     else:
  55.         return False
  56.    
  57. #-------------------------------------------------------------------------
  58.  
  59. questions = {
  60. "Where was I born?: ": "A",
  61. "Would you like to smell my fingers??: ": "B",
  62. "Who has the best Coding website?: ": "C",
  63. "Is the earth flat?: ": "A"
  64. }
  65.  
  66.  
  67. options =[["A. Canada", "B. Pakistan", "C. Russia", "D. In a parking lot"],
  68.          ["A. YES!", "B. NO!!!", "C. Maybe", "D. So"],
  69.          ["A. CodedSkills.net", "B. 1337tutorials.net", "C. CodedSkills.net", "D. 1337tutorials.net"],
  70.          ["A. True","B. False", "C. sometimes", "D. What's Earth"]]
  71. new_game()
  72.  
  73.  
  74. while play_again():
  75.     new_game()
  76. print("Byeeeee!")
Advertisement
Add Comment
Please, Sign In to add comment