Page 26 - 2501_KVS_C-7
P. 26
Variable Naming Convention:
Each language has its own set of rules to declare and initialise a variable. Python also has a
set of conventions to follow when naming a variable:
1. A variable name can include letters, digits, and underscores.
2. A variable name should be user-friendly.
3. Variable names are case-sensitive.
4. A variable name cannot start with a digit.
5. A variable name cannot contain space characters.
Let’s take some examples and understand valid and invalid variable names:
Name, first.name, 2ndName, amount in $
In the above examples, only Name is a valid identifier or variable name.
Read the conventions and try to identify the reason for the invalid variable names.
Variable names are case-sensitive, which means names written in lowercase and uppercase
are treated as two different variables — like Age and age, which are two different variables.
Assigning Values to a Variable:
To assign a value to a variable, an equal sign (=) is used.
Age = 23
Here, Age is a variable with the value 23.
2.4.3 Data type
Now, how much memory a variable occupies depends on the type of data it is assigned.
Therefore, data types determine the amount of memory required to store the variable.
Python supports five standard data types:
1. Number: The data types that store numeric values are called Python numbers. Python
has three kinds of numeric values: integer, float, and complex.
Example:
X = 89 # X is an integer variable
Y = 89.6 # Y is a float variable
Z = 23j # Z is a complex variable
2. String: A string is a sequence of characters. These sets of characters are represented
using either single quotes (‘ ‘) or double quotes (“ “).
Example:
Name = “Akbar”
# or
Name = ‘Akbar’
24 KVS DELHI REGION 2025

