ProgrammingHardProduct Company SDE · Python internals

What does the following Python 3 code print? try: def f(a, b): return a + b f(1) except TypeError: print("TypeError")

  1. A. None
  2. B. TypeError
  3. C. 1
  4. D. NameError

Correct answer: B. TypeError

f requires two positional arguments; calling it with only one raises TypeError for the missing argument.

More Python Programming questions

Exams that ask this topic