ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
from functools import partial
f = partial(int, base=2)
print(f('101'), f('11', base=10))
  1. A. 5 11
  2. B. 5 3
  3. C. 101 11
  4. D. 5 10

Correct answer: A. 5 11

partial stores base=2 as a default keyword, and a keyword passed at call time overrides it. So f('101') is 5 and f('11', base=10) is 11.

More Python Programming questions

Exams that ask this topic