This is a simple question on Function Parameters and Default Values.
It assesses knowledge 🤓 of function parameter passing, default values, and positional and keyword arguments in Python.
What will be the output of the following code:
def my_func(a, b=2, c=3):
print(a, b, c)
my_func(1, c=4)
Select an option:🤔🧐
D: is the correct answer.
In the my_func
function, there are three parameters: a
, b
, and c
. The b
and c
parameters have default values of 2 and 3, respectively.
When calling my_func(1, c=4)
, the value 1 is assigned to a
, and the value 4 is explicitly assigned to c
. Since no value is provided for b
, it takes its default value of 2.
Therefore, the function will print: 1 2 4.