Functions and Scopes
Learning Path ⋅ Skills: Python, Functions, Scope, Arguments, Parameters, Return, Globals
Enhance your Python skills by mastering functions and scope. This path covers defining functions, optional arguments, special parameters, return
statements, None
, namespaces, and global variables. Perfect for writing cleaner, more efficient code.
Functions and Scopes
Learning Path ⋅ 7 Resources
Course
Defining and Calling Python Functions
Learn how to define and call your own Python function. You'll also learn about passing data to your function and returning data from your function back to its calling environment.
Course
Defining Python Functions With Optional Arguments
Learn about Python optional arguments and how to define functions with default values. You'll also learn how to create functions that accept any number of arguments using args and kwargs.
Tutorial
What Are Python Asterisk and Slash Special Parameters For?
Learn how to use the Python asterisk and slash special parameters in function definitions. With these symbols, you can define whether your functions will accept positional or keyword arguments.
Course
Using the Python return Statement Effectively
Learn how to use the Python return statement when writing functions. Additionally, you'll cover some good programming practices related to the use of return. With this knowledge, you'll be able to write readable, robust, and maintainable functions in Python.
Interactive Quiz
The Python return Statement
Course
Python's None: Null in Python
Learn about the NoneType object None, which acts as the null in Python. This object represents emptiness, and you can use it to mark default parameters and even show when you have no result. None is a tool for doing everything with nothing!
Course
Navigating Namespaces and Scope in Python
Learn about Python namespaces, the structures used to store and organize the symbolic names created during execution of a Python program. You'll learn when namespaces are created, how they are implemented, and how they define variable scope.
Course
Working With Global Variables in Python Functions
Learn how to use global variables in Python functions using the global keyword or the built-in globals() function. You'll also learn a few strategies to avoid relying on global variables because they can lead to code that's difficult to understand, debug, and maintain.
Interactive Quiz
Using and Creating Global Variables in Your Python Functions
Got feedback on this learning path?
Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!