Python utilizes a scope resolution rule known as LEGB, which dictates the order in which Python searches for variable names: Local (L): This scope encompasses names defined within the current function. If a variable name is found in the local scope, Python uses that value. Enclosing function locals (E): If the name is not found locally, Python searches the scopes of any enclosing functions (in nested functions). Global (G): If the name is not found in any enclosing scopes, Python looks in the global scope, which includes names defined at the top level of the module. Built-in (B): Finally, if the name is not found in the global scope, Python checks the built-in scope, which contains pre-defined functions and constants.
If a variable is assigned a value within a function, it is generally considered local to that function, unless explicitly declared as global using the global keyword. Variables defined outside of any function are considered global and can be accessed from within functions, although their values can only be modified within a function if declared global.
02:10Okay, now, as I gave you a example, the variable, the scope of a house, the other thing is accessible to the house, the other thing is accessible to the house, but the other thing is accessible to the house.
02:25However, if I print the phone again, I call this function, my home, and let's see what we get.
02:39Run.
02:40Before we get the phone on the road, the phone on the home.
02:43Interesting.
02:44Okay, now I have to think that if I put it on the phone, we will get the same result, phone on the home and phone on the road.
02:55Imagine that you have a phone
02:58and you have a phone misplaced.
03:02If you have a phone, you don't exist.
03:04You don't have a phone.
03:06So, where do you see that phone?
03:09Of course, if you go back and see that
03:11that you don't have a phone.
03:13So, if you go back and see that phone,
03:16then you have a phone.
03:19Look, I have removed this phone.
03:21You have a phone.
03:22So, I have a phone.
03:24I have a phone.
03:26You can see that you have a phone on the phone.
03:28You have a phone on the phone.
03:30So, I have returned it on the phone.
03:33Interesting.
03:34Now, I have to go back and see that
03:36if I have a function
03:38wrap up.
03:40I have a function.
03:42Def parents home.
03:45It is a function.
03:46It's a function.
03:48It's a function.
03:50My home is in my parents' home.
03:53Okay?
03:54My home is in my parents' home.
03:56Now, basically,
03:58my phone is in my parents' home.
03:59I will say that
04:01my phone is in my parents' home.
04:03is on home and this is on parents home, parents, on parents home,
04:16home.
04:20Now, if you have a phone in your house, if you don't have a phone,
04:27if you don't have a phone in your house,
04:36then if you don't have a phone in your house,
04:40then you can see a phone in your house and see how you can use them.
04:47Now, when I call me, Nobody is wearing the phone in my house.
04:49reason is that it is return not to me so I will return my home
04:58return my underscore home so I will return my home
05:03my home function call sorry parents function call
05:06Okay my bad guys, I have parents spelling and function call, so I close this function
05:18and call it. I hope that you can see it again. Interesting. Now look at this.
05:27Basically, this is a memory address show, and this is a memory address.
05:33This is a memory address. This is a memory address.
05:37Basically, we have to do this function call.
05:41Now look at this function.
05:43Now look at this function.
05:45I need a variable to find a function.
05:49Now look at this method.
05:51First of all, I can see my home, my function.
05:55If my phone is a phone, I can see my parents' house.
05:59I can see my parents' home.
06:01Remember that this function is a nested function.
06:03The function inside function is a function.
06:05I can see my simple terms.
06:07I will not use this function.
06:09I will not use this function.
06:11This example will be ingrained in your mind.
06:13If you don't have a variable in your home,
06:15then you can see your parents' home.
06:17Now look at this function.
06:19Now look at this function.
06:21There is a variable in parents' function.
06:23And that is iPhone 10 on parents' home.
06:25So you can see your apps display on iOS 10 on account.
06:27So you can see my phone on the road display.
06:31Okay.
06:32So I run this function just to remove the confusion.