Page 30 - CloudGPT_C6_Flipbook
P. 30
Scope of a variable
While creating a variable, you should also remember the limits of its usage. For example,
the boxes that your mother named, can be used in the kitchen and rarely outside of the
kitchen. Similarly, a variable can also be used in specific areas of a code, known as scope of
a variable.
The scope or accessibility of the variables defined in a program depends where you have
declared it in each program. Variable defined outside the scope cannot be accessed.
NAMING VARIABLES
Every variable in a program is unique and you need to allocate
variable a unique name. You cannot use the same name of a
variable more than once.
Variable name acts as an identifier for that variable and
suggest the information which it contains.
Coding fact
In Covid-19 pandemic time, Avi Schiffmann, a teenager, coded one of the most visited
website across the globe ' ncov2019.live', to monitor COVID-19.
Example: If variable 'x' stores value 3, variable 'y' stores value 3. When Subject Enrichment
we perform addition operation on 'x' and 'y', we will get the output as '6'.
Note: Variable is created, when you assign a value to it.
Rules for naming a variable in python:
Name your variables in such a way that it describes its purpose.
Variable name must begin with a letter or an underscore and can range from 1 to 255 characters.
No special character or spaces are allowed.
Uppercase and lowercase characters are distinct.
Keywords (reserved words) cannot be used as a variable.
Coding fact
Co-founders of Apple, Steve Jobs and Steve Wozniak, in their teenage began their coding
careers.
28 Premium Edition-VI

