Python Functions: Controlling Variable Scope with global and nonlocal
Learn how to use the global and nonlocal keywords to intentionally modify variables outside of the current function scope, ensuring predictable program state.
-
💬
مدرب ذكاء اصطناعي
اسأل عن أي درس واحصل على إجابة واضحة فورًا، في أي وقت. -
🕐
ابدأ في أي وقت
بلا جداول أو مواعيد نهائية — تعلّم بوتيرتك، وقتما يناسبك. -
🌐
بالعربية
الدروس والمهام والشهادة — كل ذلك بلغتك بالكامل.
حول هذه الدورة
Understanding how Python manages variable scope is crucial for writing reliable and maintainable code, especially when functions interact with data defined outside their local environment. This course provides a clear, foundational explanation of Python’s scope rules, enabling you to confidently read, modify, and manage global and enclosing variables using the essential global and nonlocal declarations.
What you'll learn:
* Understand the foundational LEGB (Local, Enclosing, Global, Built-in) rule set for variable resolution in Python.
* Practice defining and accessing global variables correctly within standard function definitions.
* Master the use of the global keyword to intentionally modify variables in the module-level scope.
* Apply the nonlocal keyword to manage and update variables in enclosing function scopes (closures).
* Analyze the difference between modifying mutable global objects and attempting to reassign immutable global objects within functions.
We begin by defining Python's scoping principles and local environments, followed by detailed, practical explanations of when and how to use global and nonlocal effectively through written code examples. This course is designed for absolute beginners in Python programming who are starting to work with functions and need to understand variable scope. No prior knowledge of advanced Python concepts is required.
Start reading today and bring clarity to your Python function design.
ما الذي ستحصل عليه
-
📜
شهادة إتمام
أضفها إلى ملفك على LinkedIn -
💬
مدرّس AI شخصي
عالق في دورة؟ اسأل مدرّسك المدمج أي شيء، في أي وقت. -
🎧
النسخة الصوتية مضمَّنة
تعلَّم أثناء تنقُّلك — دون شاشة -
♾️
وصول مدى الحياة
عُد متى شئت، بلا انتهاء -
📱
الهاتف أو الكمبيوتر
يعمل في أي مكان وعلى أي جهاز -
💸
استرداد خلال 14 يومًا
دون أسئلة -
⚡
قصير ومركَّز
3 ساعة من المحتوى التطبيقي
المراجعات
لا توجد مراجعات بعد — كن أول من يشارك تجربته.
الأسئلة الشائعة
ما الذي أحتاجه لأخذ هذه الدورة؟ +
يكفي هاتف أو كمبيوتر متصل بالإنترنت. بدون تثبيتات أو أجهزة خاصة.
كيف يمكنني الدفع؟ +
بالبطاقة عبر Stripe. لا نخزن بيانات البطاقة — يتولى Stripe ذلك بأمان.
هل يمكنني استرداد المال؟ +
نعم — استرداد كامل خلال 14 يومًا، دون أسئلة.
إلى متى يستمر وصولي؟ +
إلى الأبد. بمجرد الشراء، الدورة لك تعود إليها متى شئت.
هل سأحصل على شهادة؟ +
نعم. عند الإتمام ستحصل على شهادة يمكنك إضافتها إلى ملفك في LinkedIn.
مصمَّم للعاملين في
التقنية
التصميم
المالية
التسويق
الرعاية الصحية
التعليم
الضيافة
التصنيع
×2
اشحن مرة واحدة وادفع النصف
أضف Rp 1.580.000 واحصل على 200 رصيد، بحيث تكلف كل دورة حوالي Rp 197.500,00. لا تنتهي صلاحية الأرصدة أبداً.
Rp 1.580.000
200 رصيد
Rp 197.500,00 / دورة
أفضل قيمة
Rp 3.960.000
550 رصيد
Rp 180.000,00 / دورة
Rp 7.920.000
1200 رصيد
Rp 165.000,00 / دورة
الرصيد يصلح لأي دورة ولا ينتهي.