Let’s carefully walk through this step by step.
Code:
Step 1: Function definition
-
The function func takes three parameters:
a → required
b → required
c → optional (default value 5)
If you don’t pass c, it will automatically be 5.
Step 2: Function call
func(1, c=10, b=2)1 → goes to a (first positional argument).
b=2 → keyword argument, so b = 2.
c=10 → keyword argument, so it overrides the default c=5.
Step 3: Values inside the function
Now inside func:
-
a = 1
- b = 2
- c = 10
Step 4: Output
The print statement runs:
print(a, b, c) # 1 2 10✅ Final output:
⚡ Key Takeaway:
-
Positional arguments come first.
-
Keyword arguments can be passed in any order.
-
Defaults are only used when you don’t override them.


0 Comments:
Post a Comment