Computer Science I / Functions and Parameter Passing
Practice question · Select all that apply

Select every statement about scope that is true.

Hints
  1. Two options invert what the lesson says about locals and about globals.
  2. The lesson calls heavy reliance on globals a drawback, not a benefit.
Show the answer
  • A. A variable declared outside all functions is global
  • C. A variable created inside a function is local to that call
  • D. Local scope lets two functions each use a variable named i without conflict
Why

Locals are confined to their call and vanish on return, so they cannot be read afterward; a name outside all functions is global; and local scope is exactly what lets two functions reuse the name i safely. The lesson warns that leaning on globals makes code harder to reason about, so the fifth option is false.

Read the lesson: Functions and Parameter Passing →

Practise Functions and Parameter Passing

The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Functions and Parameter Passing