Module 4 · How functions communicate with their environment · Lesson 1 of 5
Parameterized functions
A function that always does exactly the same thing is limited. The power comes from feeding it different data each time you call it. You do that with parameters: named slots, listed in the parentheses of the def, that stand in for values the caller will supply.
Two words are easy to mix up, so let's pin them down. A parameter is the name in the definition (the empty slot). An argument is the actual value you pass at the call (what fills the slot). Watch one fill the other:
Inside the function body, the parameter behaves like an ordinary variable — it just happens to start out holding whatever argument was passed in. List several parameters by separating them with commas, and the function can work with several inputs at once.
So far we've passed arguments in a simple, natural order. But how does Python decide which argument lands in which parameter? That's the next two lessons — first by position, then by name.