🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Exceptions and Files: all 15 questions

Quiz: Exceptions and Files · Question 7 of 15

What does this print? (code)

What does this print?

try:
    x = int("5")
except ValueError:
    print("bad")
else:
    print(x + 1)
  1. A.bad
  2. B.6
  3. C.5
  4. D.An error
Answer & explanation

Correct answer: 6

No error, so the else block runs.

Can you get the rest right without peeking?

Take the timed Quiz: Exceptions and Files quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →