Skip to content
KALANBLON
Show contents

Chapter 2 of 6 · 10 min

Quiz: handling errors

Reading a traceback, catching an error, raising one: let's check that exceptions hold no more secrets for you. You need 70 % correct answers, and every answer is explained.

Quiz

5 questions · pass mark: 70%

  1. 1.What does this program display?

    One answer

    try:
        n = int("12a")
        print("A")
    except ValueError:
        print("B")
    print("C")
  2. 2.When does the finally block run?

    One answer

  3. 3.Which good practices apply to exceptions? (several answers)

    Several answers possible

  4. 4.Complete to refuse a negative age.

    Complete the code

    if age < 0:
        _____ ValueError("negative age")
  5. 5.The traceback ends with KeyError: 'price'. What happened?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.