Better Programming

Advice for programmers.

Follow publication

Python Parameters and Arguments Demystified

Everything you need to know about parameters, arguments, and their types in Python

Chetan Ambi
Better Programming
Published in
6 min readFeb 22, 2021

Hands typing on a laptop computer.
Source: Unsplash

What are parameters and arguments? Most of the time we use the terms interchangeably — and that’s fine. However, it’s important that you understand the difference between the two. In this article, we’ll explore them in detail. Along the way, you’ll learn all you need to know about parameters and arguments in Python.

Note: If any of the features discussed below give syntax errors, please ensure you’re using a recent version of Python — 3.8 or 3.9.

Parameters and Arguments

Parameters

Parameters are the names that appear in the function definition. In the example below, name, age, and skill are the parameters as they appear in the function definition.

def my_func(name, age, skill):
pass
Image by author

Arguments

Arguments are the names that appear in the function call. In the below example, ‘Chetan’, 33, and ‘Python’ are the arguments as they appear when making a call to the function my_fync.

my_func('Chetan', 33, 'Python')

Types of arguments

There are two types of arguments. In the next section you will see how these arguments work, with examples, but first, let’s explore the syntax.

Keyword arguments

Keyword argusment is preceded by identifier/variable in the function call. In the above example, "chetan" and 33 are the keyword arguments. As you can see, they’re preceded by identifiers name and age. Keyword arguments follow key=value pairs syntax. These are also called named arguments.

Image by author

Positional arguments

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Chetan Ambi
Chetan Ambi

Written by Chetan Ambi

Data Science | Data Engineering | Big Data | Python | PySpark | Azure. Visit https://pythonsimplified.com

Responses (3)

Write a response