Python › Functions & Scope
What is the difference between positional arguments and keyword arguments when calling a function?
BeginnerAnswer
Positional arguments are matched to parameters by ORDER; keyword arguments are matched by explicit NAME (param=value), letting you pass arguments out of order and making the call site more self-documenting — a function call can freely mix both, positional first.
def greet(name, greeting):
return f"{greeting}, {name}!"
greet("Sam", "Hello") # positional
greet(name="Sam", greeting="Hi") # keyword, order doesn't matter
greet("Sam", greeting="Hey") # mixedReal-world example Making a function call with many parameters more readable by using keyword arguments for less-obvious values.