Variable Scope

This lesson discusses the scope of variables including the local and global variables.

Introduction #

The scope of a variable refers to the variable’s visibility, i.e., which part of the program can access that variable.

Types of Variables #

There are two types of variables depending on the scope (or visibility):

  • local variables
  • global variables

Local Variables #

Variables that are defined within a function are inside a local scope hence are called local variables. These variables cannot be accessed outside of the function they are declared in.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy