0Pricing
Python Academy · Lesson

Return Values and Scope

Understand return statements and variable scope (local vs global).

Introduction

Understanding return statements and variable scope is fundamental to writing predictable, bug-free Python functions.

The return Statement

return expr exits the function and sends expr back to the caller. return without a value sends None.
def double(x):
    return x * 2
print(double(5))

All lessons in this course

  1. Defining and Calling Functions
  2. Default and Keyword Arguments
  3. args and kwargs
  4. Return Values and Scope
← Back to Python Academy