Skip to content
← Python for AI/ML · all 50 levels

Scope

Level 37 of 50 · Functions

Level 37 of 50

Scope

explained with home WiFi. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaMy home WiFi works perfectly. At uni? NOTHING!
TeacherSome things only work in their own place! Python calls that scope!
balance.py
balance = 500
def call():
    cost = 20
    print(balance - cost)

call()
print(cost)
Teacherbalance is outside, so it's global. cost is inside the function!
SanaWhy does the LAST line crash?
Teachercost is local! It disappears when the function ends!

⏸ Pause & predict: what prints?

x = 10
def change():
    x = 99

change()
print(x)

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.