Python - What is the output: default parameter value and passing sequence?


What is the output of the following code?

def func(a, b, c=5): 
    print(a, b, c) 

func(1, c=3, b=2) 

Click to view the answer

1 2 3


1 is passed to a by position, and b and c are passed 2 and 3 by name.

The left-to-right order doesn't matter when keyword arguments are used like this.

Related Quiz