TV game shows
The host reads a question, checks your answer, and adds points.
12GAME PROJECTS · QUIZ
Build a game that asks questions, checks the answers, and counts your points.
IN REAL LIFE
Ask, answer, check, count. Quizzes are everywhere.
The host reads a question, checks your answer, and adds points.
Everyone answers on a screen, and the app shows the score at the end.
A question on the front, the answer on the back. You count how many you got.
THE PLAN
Each step uses something you already learned.
One list keeps the questions, the other the answers, in the same order.
[ ] questions[i]
A for loop goes through every question and asks it with input().
for range() input()
lower() ignores capitals. If the answer matches, add 1 to the score.
if lower() + 1
After the loop, if and elif pick a message for the score.
if elif else
RUN IT
Guess first. Then run real Python and check.
Read the game in the editor. Then look at PyBot's answers.
PyBot's answers: 5, Blue, cusco
What score does Python show?
PyBot's hint
Ready. Press Run Python.
Pyodide 314.0.3 runs CPython in your browser with WebAssembly.
Open-source under the Mozilla Public License 2.0. License
Now change one thing: Write your own question and answer at the end of each list, then change range(3) to range(4).
BUILD IT
Each task builds one part of a quiz. Match the goal.
The player typed BLUE and lost the point. Use lower() so capitals do not matter.
What color is the sky? BLUE Correct!OUTPUT
Both answers are right, but the score stays 0. Add the missing line.
2 + 2? 4 Correct! 3 + 3? 6 Correct! Score: 2OUTPUT
Follow the comments. Add an elif and an else so 1 point shows the right message.
Good try!OUTPUT
YOUR TURN
Try each tiny question. A wrong answer becomes something to review.
questions = ["2 + 3?", "Sky color?", "Capital of Peru?"]
print(questions[1])What will Python show?
questions = ["2 + 3?", "Sky color?"]
answers = ["blue", "5"]A player answers 5 to "2 + 3?". What happens?
for i in range(3):
print(i)Which numbers does i take?
reply = "LiMa"
print(reply.lower())What will Python show?
answers = ["Lima"]
reply = "lima"
if reply.lower() == answers[0]:
print("Correct!")
else:
print("Oops!")What will Python show?
The quiz has 3 questions. The player gets 1 right and 2 wrong.
score = 0
...
score = score + 1What is the score at the end?
score = 0
if score == 3:
print("Perfect! You are a quiz star.")
elif score == 2:
print("Great job!")
else:
print("Keep practicing!")What will Python show?
Want a fresh start? Clear only this page.
Keep questions and answers in lists, ask each one with for, and let the score decide the final message.