What's the difference between a parameter and an argument?

Another pair of terms that are easy to confuse.

What's the difference between a parameter and an argument?
Photo by Karthik Swarnkar / Unsplash
💡
This is part of an on-going series in python basics. Check the coding 101 article tag index from time-to-time for more content.

Here's another terminology pair that's commonly confused in programming: parameter and argument. What's the difference?

  • A "parameter" is the name of the data being passed in.
  • An "argument" is the actual value of the data going in.

This will probably make more sense with an example. Let's say I have some python code that looks like this:

def greet(name):
    print(f"Hello {name}, how are you today?")
    print("What a beautiful day is it today!")

greet("Bob")

At the top, I'm defining a function. It's not doing anything fancy; just giving back a personalized greeting with a name. The line at the very bottom actually uses the function. It passes over the string value "Bob" for the program to use during execution.

In this example, (name) is my parameter. It's the code-level label for the data that I'll be feeding into the function.

"Bob" is my argument. It's the actual value/entry for the name that I'm sending to the code.

Make sense? The reason why there's multiple terms here is for clarity. If I'm helping someone debug something, maybe we don't care what the actual data is. If there's a high-level coding flaw, we might not need to process user data at all. On the other hand, maybe there's something odd about a specific type of data that a user is entering. Having a term for each perspective and stage in code development is helpful.