0Pricing
Learn AI with Python · Lesson

Return Values

Discover how to use return values to make functions more versatile.

1

Introduction to Return Values

Return values allow functions to send data back to the part of the program that called them. This makes functions more versatile and reusable.

In this lesson, you will learn how to use return values effectively in Python functions.

Return Values — illustration 1

2

What is a Return Value?

A return value is the output of a function. You can use the return keyword to send data back to the caller.

For example:

# Function with a return value
def add(a, b):
    return a + b

result = add(3, 5)
print(result)

All lessons in this course

  1. What is a Function?
  2. Return Values
  3. Scope and Lifetime of Variables
  4. Built-in Functions vs. User-Defined Functions
  5. Importing Modules
← Back to Learn AI with Python