0% found this document useful (0 votes)
4 views1 page

Python Quiz Game Code Example

This document outlines a Python quiz game that presents five questions with multiple-choice answers. Players input their guesses, which are compared to the correct answers, and their score is calculated based on the number of correct responses. The game concludes by displaying the correct answers, the player's guesses, and the final score as a percentage.

Uploaded by

tauthegoat10
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)
4 views1 page

Python Quiz Game Code Example

This document outlines a Python quiz game that presents five questions with multiple-choice answers. Players input their guesses, which are compared to the correct answers, and their score is calculated based on the number of correct responses. The game concludes by displaying the correct answers, the player's guesses, and the final score as a percentage.

Uploaded by

tauthegoat10
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

# Python quiz game

questions = ("How many elements are there in the periodic table?: ",
"Which animal lays the largest eggs?: ",
"What is the most abundant gas in Earth's atmosphere?: ",
"How many bonesa are there in the human body?: ",
"Which planet in the solar system is the hottest?: ")

options = (("A. 116", "B. 117", "C. 118", "D. 119"),


("A. Whale", "B. Crocodile", "C. Elephant", "D. Ostrich"),
("A. Nitrogen", "B. Oxygen", "C. Carbon-Dioxide", "D. Hydrogen"),
("A. 206", "B. 207", "C. 208", "D. 209"),
("A. Mercury", "B. Venus", "C. Earth", "D. Mars"))

answers = ("C", "D", "A", "A", "B")


guesses = []
score = 0
question_num = 0

for question in questions:


print("--------------------------------")
print(question)
for option in options[question_num]:
print(option)

guess = input("Enter (A, B, C, D): ").upper()


[Link](guess)
if guess == answers[question_num]:
score += 1
print("CORRECT")
else:
print("INCORRECT!")
print(f"{answers[question_num]} is the correct answer")
question_num += 1

print("--------------------------------")
print(" RESULTS ")
print("--------------------------------")

print("answers: ", end ="")


for answer in answers:
print(answer, end=" ")
print()

print("guesses: ", end ="")


for guess in guesses:
print(guesses, end=" ")
print()

score = int(score / len(questions) * 100)


print(f"Your score is: {score}%")

You might also like