Lesson - 24 : Python3 - Python Function : Global variables vs local variables

Опубликовано: 20 Декабрь 2017
на канале: Sada Learning Hub
54
2

**************************************************
Python Core PlayList :    • Lesson - 01 : Python3 - What is python  
Python Advanced PlayList :    • Lesson - 46 : Python Advanced - Python OOP...  
**************************************************

Python Function : Global variables vs local variables:
Local Variables:
Variables declared inside a function body is known as Local Variable. These have a local access thus these variables cannot be accessed outside the function body in which they are declared.

Global Variable:
Variable defined outside the function is called Global Variable. Global variable is accessed all over program thus global variable have widest accessibility.

Example :
xy = 100
def cool():
    xy = 200     # xy inside the function is totally different from xy outside the function
    print(xy)    # this will print local xy variable i.e 200
 
cool()
 
print(xy)        # this will print global xy variable i.e 100

Sample Projects : https://github.com/SadaLearningHub1/P...


На этой странице сайта вы можете посмотреть видео онлайн Lesson - 24 : Python3 - Python Function : Global variables vs local variables длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Sada Learning Hub 20 Декабрь 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 54 раз и оно понравилось 2 зрителям. Приятного просмотра!