LearnFrenzy
Sign in Take a free test

Exception Handling · Predict the Output · Question 11

try, except, else and finally together Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What is the output of the following Python program?

main.py
def run(d):
    try:
        print("T", end="")
        value = 10 // d
    except ZeroDivisionError:
        print("E", end="")
    else:
        print("L", end="")
    finally:
        print("F")

run(2)
run(0)
  • A TELF TEF
  • B TLF TEF Correct
  • C TLF TLF
  • D TF TEF
Correct Answer: Option B

Success runs try, else, finally; failure runs try, except, finally.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links