Programming Concepts Tutorial

Learn the fundamental concepts of computer programming

Scope

Variable Scope

Scope refers to the visibility and accessibility of variables in different parts of your code.

Global vs Local Scope

  • Global Variables: Variables declared outside of any function. They can be accessed from anywhere in the program.
  • Local Variables: Variables declared inside a function or block (like a loop). They can ONLY be accessed from within that specific function or block.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics