Pythondex

Tutorial

Returning Values from Functions

Functions can return values using the return statement. This allows the function to send data back to the caller.

Defining a Function that Returns a Value

Using the Returned Value

Using Returned Values Directly in Expressions

Returning Multiple Values

Returning Different Data Types

Summary

  • The return statement sends a value back to the caller, which can be stored in a variable or used directly
  • Functions can return any data type (int, float, string, list, tuple, etc.)
  • Functions can return multiple values using tuples
  • Using return makes your code reusable and modular
  • You can use returned values directly in expressions or calculations