Python quiz game 💯

Published: 13 January 2021
on channel: Bro Code
140,381
3.6k

python quiz game project tutorial example explained

#python #quiz #game

-------------------------
def new_game():

guesses = []
correct_guesses = 0
question_num = 1

for key in questions:
print("-------------------------")
print(key)
for i in options[question_num-1]:
print(i)
guess = input("Enter (A, B, C, or D): ")
guess = guess.upper()
guesses.append(guess)

correct_guesses += check_answer(questions.get(key), guess)
question_num += 1

display_score(correct_guesses, guesses)

-------------------------
def check_answer(answer, guess):

if answer == guess:
print("CORRECT!")
return 1
else:
print("WRONG!")
return 0

-------------------------
def display_score(correct_guesses, guesses):
print("-------------------------")
print("RESULTS")
print("-------------------------")

print("Answers: ", end="")
for i in questions:
print(questions.get(i), end=" ")
print()

print("Guesses: ", end="")
for i in guesses:
print(i, end=" ")
print()

score = int((correct_guesses/len(questions))*100)
print("Your score is: "+str(score)+"%")

-------------------------
def play_again():

response = input("Do you want to play again? (yes or no): ")
response = response.upper()

if response == "YES":
return True
else:
return False
-------------------------


questions = {
"Who created Python?: ": "A",
"What year was Python created?: ": "B",
"Python is tributed to which comedy group?: ": "C",
"Is the Earth round?: ": "A"
}

options = [["A. Guido van Rossum", "B. Elon Musk", "C. Bill Gates", "D. Mark Zuckerburg"],
["A. 1989", "B. 1991", "C. 2000", "D. 2016"],
["A. Lonely Island", "B. Smosh", "C. Monty Python", "D. SNL"],
["A. True","B. False", "C. sometimes", "D. What's Earth?"]]

new_game()

while play_again():
new_game()

print("Byeeeeee!")

-------------------------

Bro Code merch store 👟 :
===========================================================
https://teespring.com/stores/bro-code-5
===========================================================

music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi   / kubbi  
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library    • Up In My Jam (All Of A Sudden) – Kubbi (No...  
===========================================================


On this page of the site you can watch the video online Python quiz game 💯 with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 13 January 2021, share the link with friends and acquaintances, this video has already been watched 140,381 times on youtube and it was liked by 3.6 thousand viewers. Enjoy your viewing!