0% found this document useful (0 votes)
39 views2 pages

Basic Quiz Game ABCD

The document contains a Python script for a quiz game that allows users to answer multiple-choice questions. It tracks user guesses, checks answers, and displays the score at the end of the game. The game can be replayed based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Basic Quiz Game ABCD

The document contains a Python script for a quiz game that allows users to answer multiple-choice questions. It tracks user guesses, checks answers, and displays the score at the end of the game. The game can be replayed based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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_quesses, 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_quesses/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 = {
"Red vegetable?: ": "A",
"Blue fruit?: ": "B",
"What year?: ": "C",
}

options = [
["A. Bell Pepper", "B. Onion", "C. Garlic"],
["A. Strawberry", "B. Blueberry", "C. Lemon"],
["A. 2021", "B. 2022", "C. 2023"]
]

new_game()

while play_again():
new_game()

print("End of the game")

You might also like