Lesson Complete!

The Player's Answer

You finished Python Basics. Over three lessons you built a working terminal quiz from scratch, one piece at a time.

Here is the complete quiz.py:

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}")
print()
answer_text = input("Your answer (1-4): ")
answer = int(answer_text)
is_correct = answer == correct
print()
print(f"You answered: {answer}")
print(f"Correct: {is_correct}")

What the program does, end to end:

  • Stores the question, options, and correct answer in variables
  • Prints the quiz title, question, and four numbered options
  • Waits for the player to type a number and press Enter
  • Converts the input from a string to an integer
  • Checks if the answer matches the correct option and stores True or False
  • Displays what the player chose and whether they got it right

What you learned:

  • print() — display text and values in the terminal
  • Variables — give data a name so you can use it anywhere in your code
  • Strings and integers — the two value types used in the quiz
  • f-strings — embed variables directly in printed text
  • input() — pause the program and collect the player's response
  • int() — convert a string to an integer
  • Comparison operators==, !=, >, <, >=, <=
  • Boolean valuesTrue and False as the result of comparisons

What's still missing: the quiz doesn't say "Correct!" or "Wrong!" — it just prints True or False. Acting on is_correct requires running different code depending on its value, and that requires if/else.

Next course — Upgrade PyQuiz: Control Flow: you will add if/else to give feedback after each answer, loops to ask multiple questions, and a score that updates as the player goes. That's when the quiz starts to feel like a real game.