Using the Python return Statement Effectively (Overview)
The Python return
statement is a key component of functions and methods. You can use the return
statement to make your functions send Python objects back to the caller code. These objects are known as the function’s return value. You can use them to perform further computation in your programs.
Using the return
statement effectively is a core skill if you want to code custom functions that are Pythonic and robust.
In this course, you’ll learn:
- How to use the Python
return
statement in your functions - How to return single or multiple values from your functions
- What best practices to observe when using
return
statements
For more information on defining your own functions, take a look at the following resources:
- Defining Your Own Python Function | Real Python Tutorial
- Defining and Calling Python Functions | Real Python Video Course
00:00
Welcome to this course on the Python return
statement: usage and best practices.
00:06
As you can see, you’ll be learning a lot, starting with the basics of Python’s return
statement, and then looking at many of the more interesting things Python can do.
00:17
The Python return
statement is a key component of functions and methods. You can use the return
statement to make your function send Python objects back to where the function was called.
00:28
These objects are known as the function’s return value, and it is intended that these objects will be used in your program’s further computations. Using the return
statement effectively is important to writing better and more Pythonic code. In this course, you will learn how to write a Python return
statement, how you can return single and multiple values with a return
statement, and what are the best practices for using the Python return
statement.
00:57 For background information on using functions in general, you should look for the tutorial and course on defining your own Python functions. This course is based on a tutorial by Leodanis Pozo Ramos.
01:10 I’m Howard Francis, and I’m excited to be leading you through this course. Let’s get started!
Become a Member to join the conversation.