IHateMyselfx

Edited_Guess

Jul 21st, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.81 KB | None | 0 0
  1.  
  2.  
  3. def game_questions():
  4.    
  5.    
  6.     guessed = []
  7.     CORRECT_GUESSES = 0
  8.     question_num = 1
  9.        
  10.     for key in questions:
  11.         print("|---------------------|")
  12.         print(key)
  13.         for i in options[question_num-1]:
  14.             print(i)
  15.         guess = input("Answer must be between A-C!\n:").upper()
  16.         guessed.append(guess)
  17.         question_num += 1
  18.         CORRECT_GUESSES += game_check_answer(questions.get(key),guess)
  19.    
  20.    
  21.     game_point_display(CORRECT_GUESSES)
  22.  
  23.  
  24.  
  25. def game_check_answer(answer,guess):
  26.     if answer == guess:
  27.         print(f"\nCorrect!\nYour guess was {guess}, and the answer is {answer}")
  28.         return 1
  29.     else:
  30.         print("worng!:(\n")
  31.         return 0
  32.  
  33. def game_point_display(CORRECT_GUESSES):
  34.     print("Results are:\n")
  35.     safe = int((CORRECT_GUESSES/len(questions))*100)
  36.     print(f"Calculation: {safe}%")
  37.     pass
  38.  
  39.  
  40.  
  41. def game_run():
  42.     score = 0
  43.     name = input("    What is your name!    \n:")
  44.     print("    Hello, " + name + "! Nice to meet you!")
  45.     print("    To give the correct answer, press the letter corresponding to the answer and then press enter")
  46.     game_questions()
  47.  
  48.  
  49. def game_start():
  50.     gamest = input("    Press x to continue!    \n:")
  51.     #Start of the program
  52.     if gamest != 'x':
  53.         gamest = input("If you wan't to quit press anything but ' x '\n:")
  54.         if gamest != 'x':
  55.             print("Closed")
  56.             quit()
  57.         else:
  58.             game_run()
  59.     else:
  60.             game_run()
  61.          
  62.  
  63.  
  64.  
  65.  
  66. questions = {
  67.         "Which is the largest country by population?": "A",
  68.         "Approximately, how many billions of people are on Earth?":"C",
  69.         "What is the symbol of the unit of measurement of electrical voltage?": "B",
  70.         "What is the measuring instrument for measuring electric current intensity?": "B",
  71.         "This one is for gamers! When was Minecraft released?": "A",
  72.         "Which is the biggest ocean?": "C",
  73.         "What is the altitude of Everest Peak?": "C",
  74.         "Where does the abbreviation RAM came from?": "B",
  75.         "Who painted the starry night?":"B",
  76.         "Which is the largest country by the aera?": "A"  
  77.     }
  78. options = [["A. China","B. Russia", "C. Canada"],
  79.             ["A. 7","B. 10","C. 8"],
  80.             ["A. I", "B. V", "C. F"],
  81.             ["A. Voltmeter","B. Ammeter", "C. Ohmmeter"],
  82.             ["A. 18 November 2011","B. 18 December 2011","C. 20 June 2010"],
  83.             ["A. The Atlantic Ocean,","B. The Indian Ocean", "C. The Pacific Ocean"],
  84.             ["A. 90000m","B. 8878m","C. 8848m"],
  85.             ["A. Read-Acces memory","B. Random-Acces memory","C. Read-Only memory"],
  86.             ["A. Leonardo Da Vinci","B. Vincent Van Gogh", "C. Tizilao Vecellio"],
  87.             ["A. Russia","B. Brazil","C. China"]]
  88.  
  89. game_start()
Advertisement
Add Comment
Please, Sign In to add comment