Python - 10
Python - 10: Mini Project - Build a Simple Quiz
Now you can combine variables, input(), if statements, and numbers to build a simple quiz game.
Your challenge: Ask three questions, add one point for each correct answer, and display the final score.
Keep track of the score
Start with score = 0. Each time the player answers correctly, increase it with: score = score + 1
Check each answer
Use an if statement to compare the user's answer with the correct answer.
For example: if answer1 == "blue":
Build several questions
Each question follows the same pattern: ask with input(), check the answer, and increase the score when it is correct.
Try it: Add a third question of your own and make sure the highest possible score becomes 3.
Good Python habit: Keep variable names like answer1, answer2, and score clear so it is easy to follow the quiz logic.
👀 Show Example Solution
print("Welcome to the Quiz!")
score = 0
answer1 = input("What color is a clear daytime sky? ")
if answer1 == "blue":
print("Correct!")
score = score + 1
answer2 = input("How many days are in a week? ")
if answer2 == "7":
print("Correct!")
score = score + 1
answer3 = input("What language are you learning? ")
if answer3 == "Python":
print("Correct!")
score = score + 1
print("Final Score:")
print(score)The quiz starts at zero points and increases score by one whenever an answer matches the expected value.
