Python Advanced Functions Tutorial Default, Keyword Arguments & Variable Scope Global vs Local

Опубликовано: 24 Март 2026
на канале: 6 Inch Python
58
like

00:00 - Intro
00:03 - Concept 1: Default Arguments
01:03 - Using Default Arguments
01:48 - Concept 2: Keyword Arguments (Flexibility)
02:53 - Concept 3: Variable Scope (The Office Analogy)
03:53 - Local Scope Demonstration
04:43 - Global Scope and The Read Rule
05:23 - Common Mistake: The Modification Trap
06:33 - Best Practice: Using the 'global' Keyword
07:48 - Practical Application: Combining Concepts (Unit Converter)
09:03 - Testing the Converter


EXERCISE:
CHALLENGE: Create a function called `volume_calculator` that accepts `length`, `width`, and `height`. All arguments must have a default value of `1.0`. The function should use keyword arguments to allow the user to only specify the `height` (e.g., `volume_calculator(height=5)`).

Welcome to an in-depth look at advanced Python function techniques. In this tutorial, Senior Python Engineer Alex walks you through Default Arguments, Keyword Argument flexibility, and the crucial concept of Variable Scope (Global and Local). Learn professional techniques and avoid common runtime errors like UnboundLocalError.