Skip to content

Sep 23: Variable Scope, Docstrings

Meet in King 248

Learning Objectives

After today's class, you should be able to:

  • Explain the difference between global and local variables.
  • Test a function under if __name__ == "__main__".
  • Use a debugger to step through a program that calls functions.

Lesson Outline

Presentation [10 min]

  • Variable scope (local vs global vs built-in)

Lab (Part 1) [40 min]

  • Slides
  • Code ← Exercises 1–3 today, 4–6 on Friday

This lab includes topics from later weeks (lists, random numbers).
We will walk through the lab as a class rather than work individually.

Your To-Do List

  • Continue working on the Week 5 study guide

Tip

Spend time on Runestone this week! The Gradescope practice programs are good practice too. But the Runestone questions are more like what you will see on the quiz: