Week 4: Functions, Scope, and Dictionaries
211 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 4: Functions, Scope, and Dictionaries > **Course:** Jan 2026 - Python > **Focus:** Reusable logic, variable scope, and key-value storage. --- ## 1.

Visual strip
Relevant recall pieces for this note
Week 4: Functions, Scope, and Dictionaries
Course: Jan 2026 - Python Focus: Reusable logic, variable scope, and key-value storage.
1. Core idea
Week 4 turns code into reusable units and names data by meaning instead of position.
What to remember
- A function stops as soon as it hits
return. - Local variables live inside the function.
- Global variables live outside the function.
- Dictionaries map unique keys to values.
.get()is safer than direct indexing when a key might be missing.
2. Common traps
- Forgetting
selfin methods. - Returning too early inside a loop.
- Using a mutable object without understanding side effects.
- Treating dictionary order as the main idea when the real idea is lookup.
3. Speedrun pattern
When you see a Week 4 question, ask:
- What is the input-output contract of the function?
- Which variables are local and which are shared?
- Is the answer about one lookup or many lookups?
4. Micro revision
- Function = reusable block
- Scope = where a name exists
- Dictionary = key-value store
Assignment anchor
Navigation
- Previous: Week 3 Notes
- Next: Week 5 Notes