Scope of Functions

Learn about the scope of the function and the difference between local and global variables.

Introduction to scope concept in functions

As you begin to use functions, you should develop an awareness of the concept of scope. Notice that when we wrote the sigmoid function, we created a variable, Y, inside the function. Variables created inside functions are different from those created outside functions. They are effectively created and destroyed within the function itself when it is called. These variables are said to be local in scope: local to the function. You are not able to access the Y variable after using the sigmoid function:

Get hands-on with 1400+ tech skills courses.