Lesson Complete!
Variables
Your quiz has real structure now. Here's what quiz.py looks like at the end of this lesson:
question = "What is the type of the value 3.14?"
option_1 = "int"
option_2 = "str"
option_3 = "float"
option_4 = "bool"
correct = 3
print("=== Python Quiz ===")
print()
print(question)
print()
print(f" 1) {option_1}")
print(f" 2) {option_2}")
print(f" 3) {option_3}")
print(f" 4) {option_4}")What you learned
- Variables: give values names with
=so you can reuse and update them in one place - Strings: text values in quotes —
"int"is the string "int", not a Python keyword - Integers: whole numbers without quotes —
correct = 3 - f-strings: embed variable values in strings with
f"...{variable}..."
What's still missing
The quiz displays the question and options, but the player can't enter an answer. Nothing yet collects input or checks whether they got it right.
In Lesson 3, you'll use input() to pause the quiz and wait for the player to type their answer.