Lesson Complete!

Right or Wrong

You finished the first lesson of Upgrade PyQuiz. The quiz now gives real feedback on every answer.

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}")
if is_correct:
    print("Correct!")
else:
    print(f"Wrong! The correct answer was option {correct}.")

What you added:

  • if statement — runs code only when a condition is True
  • else clause — handles the case when if is False

What's still missing: the quiz only asks one question. You have to run the script again to get a new attempt. In the next lesson, you will use loops to ask multiple questions in one run — and track your score across all of them.