Reference Documents
PDF versions of the content in the binders we have in class:
Explanation of Positional vs Keyword Arguments in Python
When you call a function in Python, you can give it values in two main ways:
- Positional arguments – the order matters.
Here, Python knows which value goes where just because of the position.
- Keyword arguments – you say exactly which parameter should get the value, using the parameter’s name.
In this call, 10 is still positional, but end="!!!" is a keyword argument.
You don’t have to remember its position, because you’re labeling it.
How they work together
- Positional arguments must come first in a function call.
- Keyword arguments come after positional ones.
- Mixing them is common:
So:
- Positional = order matters
- Keyword = names matter
Both are just ways of telling Python which value should go to which parameter.