codeGK
Code it ALL
Python Variables - CodeGK
♦ Python Variables

♣ About Python Variables

Variables are Dummy data types which hold the value of Actual Data Types.
Variables are not compulsory for writing programs, but they come extremely handy for organization and generalization of code.
Example
Input:
Output:

♣ Local Variable in Python

A variable defined in particular scope can be only accessed in that part of the code block, such variables are called Local Variables.
For Example, the variables defined inside the function can only be accessed from internal code block of function.
Example
Input:
Output:

♣ Global Variable in Python

A type of variable that can be accessed from any part of the code is called a global variable(of course, the accessing should be from below of the definition of the variable). For example, a variable which is initialized globally(outside of all functions and outside of all classes) can be accessed from anywhere(inside/outside of functions/classes).
Example
Input:
Output:
Prev_LessonNext_Lesson