Skip main navigation

What’s the difference between arguments and parameters?

Learn algorithms, logic, and Python basics. Create simple programs, grasp computer science fundamentals, and see its impact across various fields.

Parameters

While exploring functions, the word parameter was introduced. Parameters are defined variables in the function that are required for the function to perform its computation.

For example, the following function has 2 parameters, num1 and num2:

def add(num1, num2):
   return num1 + num2

These are expected values that we need to pass to the function when we call it.

Remember that when you want to call the above function, you need to run the following code:

add(4, 3)

In this example, the add function is called, and the values 4 and 3 are passed in to the parameters num1 and num2. So in the function add, when called as shown above, num1=4 and num2=3. That’s because the value 4 is passed first and the value 3 second. So when Python executes the code, it will pass the number 4 to num1 and number 3 to num2 in the function.

Arguments

Another important related term is argument. In Python and other programming languages, the term argument means something slightly different from parameter.

A parameter is what is defined in the function definition (num1, num2 etc) and an argument is the values being passed to the function. So in the above example, num1 and num2 in the line def add(num1, num2) are parameters and the values 4 and 3 in the line add(4, 3) are arguments passed to the function’s parameters.

Another example is shown in the following code:

def add(num1, num2):
   return num1 + num2

num1 = 3
num2 = 4
add(num1, num2)

Here num1 and num2 in line 1 are the function’s parameters and num1 and num2 in lines 4 and 3 are the arguments. You can have variables as the arguments.

Summarising the difference

So the distinction is:

when you call a function, you pass arguments

when you define a function, you define parameters.

This article is from the free online

An Introduction to Programming Using Python

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now