Mini-Project: The Scope Investigator

Write four small functions that each demonstrate one scope rule: (1) a local variable that is invisible outside, (2) a global read from inside a function, (3) a shadowed global that stays unchanged, (4) a counter that fails to accumulate because its variable is local. Print a short label before each demonstration so the output reads like a lab report. Then write a fifth function that DOES accumulate correctly by taking a running total as a parameter and returning the new one. Both languages.

SANKOFA SANDBOX
loading editor…
Your turn → Work through it step by step. This is a piece of the course project, not a throwaway exercise.

Built it in both languages?

Mark it done once your Python and JavaScript versions both run correctly. Honesty here is what makes the dashboard useful to you.

← BackNext: Module 17: Data Conversion and Parsing →