What does a compiler do?

That’s correct! A variable’s scope defines the parts of a program that can “see” that variable.

==============================