Week 4: Functions, Scope, and Dictionaries

211 words
1 min read
Python Week 1: the first filter for runtime behavior
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

Open gallery

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 self in 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:
  1. What is the input-output contract of the function?
  2. Which variables are local and which are shared?
  3. 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

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.