Search⌘ K

Scope of Functions

Explore the concept of variable scope in Python functions, focusing on the difference between local and global variables. Understand how scope impacts the creation and use of variables within logistic regression functions and apply this knowledge to improve your coding and modeling techniques.

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: ...