ProgrammingHardWipro · Accenture · Capgemini pattern

What does the following Python 3 code print? def f(a, b, *args): return a, b, args print(f(1, 2, 3, 4, 5))

  1. A. (1, 2, (3, 4, 5, 5))
  2. B. (1, 2, 3, 4, 5)
  3. C. (1, 2, (3, 4, 5))
  4. D. (1, 2, [3, 4, 5])

Correct answer: C. (1, 2, (3, 4, 5))

a and b take the first two positional values; every remaining positional argument is collected into the args tuple.

More Python Programming questions

Exams that ask this topic