Positional and Keyword Arguments

You’ll resume the video course later. Here’s a short extract from a Real Python tutorial to wrap up the topic of positional and keyword arguments.

This text is part of a Real Python tutorial by John Sturtz.


Positional Arguments

The most straightforward way to pass arguments to a Python function is with positional arguments (also called required arguments). In the function definition, you specify a comma-separated list of parameters inside the parentheses:

Python
>>> def f(qty, item, price):
...     print(f'{qty} {item} cost ${price:.2f}')
...

When the function is called, you specify a corresponding list of arguments:

Python
>>> f(6, 'bananas', 1.74)
6 bananas cost $1.74

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

You must own this product to join the conversation.