Page 131 - C_GPT _V4 _class_6
P. 131
Topic Flashback 21 st Century
Skills #Critical Thinking
Guess my name.
1. I am a free and open-source programming language.
2. I am a command line shell which gives immediate result for each command.
3. I save the commands entered by the user in the form of a program.
4. I am an option to save the Python program.
5. I am an option to run the Python program.
VARIABLES IN PYTHON
Variables are memory reference points where we store values that can be accessed or changed later.
The names given to the variables are known as identifiers. In Python, we do not need to specify the type
of variable because Python is a dynamically typed language and identifies the variable type automatically.
Declaring and Initialising a Variable
In Python, variables are declared and initialised at the same time in the following way:
a = 10
b = 20
print ("a=", a)
print ("b=", b)
On the output screen, a = 10 and b = 20 will be printed. You can also assign the same value to multiple
variables at the same time in the following way:
a = b = 20
print ("a=", a)
print ("b=", b)
On the output screen, a = 20 and b = 20 will be printed.
You can also assign multiple values to multiple variables in the same line in the following way:
name, age, grade="Deepak", 12, "VII"
print ("Name is", name)
print ("Age is", age)
print ("Grade is", grade)
On the output screen, Name is Deepak, Age is 12 and Grade is VII will be printed.
You must follow the given rules while creating and naming the variables:
Variable names can contain letters (a-z, A-Z), digits (0-9), or an underscore (_).
Variable names must begin with a letter or an underscore.
Variable names are case-sensitive (Age and age are different variables).
Python keywords cannot be used as variable names (reserved words like if, else, for, etc.).
Variable names cannot contain spaces.
Python 129

