ProgrammingModerateInfosys · Accenture · Capgemini pattern

What is printed?

What is printed?
def f(*args, **kw):
    print(len(args), len(kw))

f(1, 2, a=3)
  1. A. 2 1
  2. B. 1 2
  3. C. 3 0
  4. D. 3 1

Correct answer: A. 2 1

Positional arguments go into the tuple args, here (1, 2). Keyword arguments go into the dict kw, here {'a': 3}. So the lengths are 2 and 1.

More Python Programming questions

Exams that ask this topic