A Guide to Passing Arguments in Python Functions
Beginner #12: Exploring positional and keyword arguments, default parameters, local and global scope, and return values
Table of Contents
What is a Function?
▹ Key Features of a Function
▹ Function Structure
Parameters vs Arguments
▹ Parameters
▹ Arguments
Passing Arguments
▹ Positional Arguments
▹ Keyword Arguments
Default Parameters
▹ How Default Parameters Work
▹ Calling the Function With and Without Default Parameter
▹ Important Points about Default Parameters
▹ Multiple Default Parameters
▹ Advantages of Default Parameters
The local and global Scope
▹ 1. Local Scope
▹ 2. Global Scope
▹ Differences Between Local and Global Scope
▹ Modifying Global Variables Inside a Function
▹ Nested Functions and Local Scope
▹ Scope Lookup: The LEGB Rule
Return Values
▹ Multiple Return Values
▹ Returning Early from a Function
▹ No Return Statement
▹ Using the Returned Value
Summary
Reference