ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE

What does the following Python 3 code print? def f(): try: return 3 finally: print("f", end=" ") x = f() + 10 print(x)

  1. A. 3
  2. B. f 13
  3. C. 10
  4. D. 0123

Correct answer: B. f 13

A finally block always runs before the function actually returns; a return inside finally would override the earlier return value. Output: f 13.

More Python Programming questions

Exams that ask this topic