In most of this quiz’s questions, results may vary slightly in 2.X—with enclosing parentheses and commas when multiple values are printed. To match the 3.X answers exactly in 2.X, import print_function from __future__ before starting.
What is the output of the following code, and why?
>>>def func(a, b=4, c=5):print(a, b, c)>>>func(1, 2)
What is the output of this code, and why?
>>>def func(a, b, c=5):print(a, b, c)>>>func(1, c=3, b=2)
How about this code: what is its output, and why?
>>>def func(a, *pargs):print(a, pargs)>>>func(1, 2, 3)
What does this code print, and why?
>>>def func(a, **kargs):print(a, kargs)>>>func(a=1, c=3, b=2)
What gets printed by this, and why?
>>>def func(a, b, c=3, d=4): print(a, b, c, d)>>>func(1, *(5, 6))
One last time: what is the output of this code, and why?
>>>def func(a, b, c): a = 2; b[0] = 'x'; c['a'] = 'y'>>>l=1; m=[1]; n={'a':0}>>>func(l, m, n)>>>l, m, n