WHAT IS A VARIABLE IN PYTHON?
• Variables are containers for storing data values given by the
users.
• A variable is a memory location to store values or data.
Example:
1. Variable starts with a letter or underscore:
Eg: school, age, or _average
2. Veriable cannot start with a number.
Eg. 123Name7
3. Variable will not have space in the middle. Eg. School Name
4. Do not use any special character like @,# %!
5. Use descriptive names: Use names that describe what the variable represents.
6. Variable is Case-sensitive. Eg. (age, Age, and AGE are three different variables)
7. Avoid using reserved keywords:
- Don't use reserved keywords as names.
- Example: Avoid using words like for, if, Else, while, def, print, etc
The guidelines or rules to follow when naming variables.
1. Variable starts with a letter or underscore:
Eg: school, age, or _average
2. Veriable cannot start with a number.
The guidelines or rules to follow when naming variables.
message_1 ✅
1_message ❌
21 aVenue❌
Avenue21✅
3.Variable will not have space in the middle.
Eg.
4.Do not use any special characters like
Eg @,# %!
5. Variables should be short and meaningful/descripti
Date of birth ❌
Date_of_birth ✅
- Students_name is better than S_N
- Name= Puja N=Puja
6. Variable is Case-sensitive.
Eg. (age, Age, and AGE are three different
variables)
7. Avoid using reserved keywords:
Eg: Avoid using words like:
for, if, else, while, def, print, or
, not, and int, float, string etc
HERE ARE SOME EXAMPLES OF VALID VARIABLE NAMES:
• myVariable
• _privateVar
• counter123
• school_name
HERE ARE SOME EXAMPLES OF INVALID VARIABLE NAMES:
• 123variable (starts with a number)
• @special (contains a special character)
• for (uses a reserved keyword)
• Stu Name (Space in the mddle)
• When the variable name is taken, you need to put something in the
variable. The format is as follows:
•= means not the equal sign in mathematics, but the assigned symbol,
which means to save the value on the right to the variable on the left.
ASSIGNING VALUES TO VARIABLES
number = 9
Output Variables
The Python print statement is often used to output variables.
To combine both text and a variable, Python uses the + character:
x = "awesome"
print("Python is " + x)
You can also use the + character to add a variable to another variable:
x = "Python is "
y = "awesome"
z = x + y
print(z)
x=("Python is")
y=("awesome")
print(x,y)
WHY WE USE VARIABLES IN PYTHON CODING?
Storage: Variables store data like numbers or text during program
run.
Reuse: You can use data stored in variables again and again.
 Manipulation: It helps to change the data easily.
Readability: Variables give data meaningful names for clear code.
Any Questions….
QUICK ASSESSMENT
ON
LESSON PRESENT
First Hand First
Q-1 Q-2 Q-3
Which is incorrect Variables as per guidelines?
A. counter123
B. _privateVar
D. Stu name
C. school_name
Which is the correct way to declare a variable in Python?
B. NAME =Puja12
A. 12name = Puja
D. -name=puja
C. #Puja=name
a) variable_name = value
b) b) value = variable_name c) value = 123 d) value123 =
123
19
21
20
22
Open Question
Thank you
&
Tashi Delek
YES!
Correct Answer !
Home
Continue
Home
Try next time , You can do it!
Continue

Python Variable for the students who started their python.pptx

  • 4.
    WHAT IS AVARIABLE IN PYTHON? • Variables are containers for storing data values given by the users. • A variable is a memory location to store values or data.
  • 5.
  • 6.
    1. Variable startswith a letter or underscore: Eg: school, age, or _average 2. Veriable cannot start with a number. Eg. 123Name7 3. Variable will not have space in the middle. Eg. School Name 4. Do not use any special character like @,# %! 5. Use descriptive names: Use names that describe what the variable represents. 6. Variable is Case-sensitive. Eg. (age, Age, and AGE are three different variables) 7. Avoid using reserved keywords: - Don't use reserved keywords as names. - Example: Avoid using words like for, if, Else, while, def, print, etc The guidelines or rules to follow when naming variables.
  • 7.
    1. Variable startswith a letter or underscore: Eg: school, age, or _average 2. Veriable cannot start with a number. The guidelines or rules to follow when naming variables. message_1 ✅ 1_message ❌ 21 aVenue❌ Avenue21✅
  • 8.
    3.Variable will nothave space in the middle. Eg. 4.Do not use any special characters like Eg @,# %! 5. Variables should be short and meaningful/descripti Date of birth ❌ Date_of_birth ✅ - Students_name is better than S_N - Name= Puja N=Puja
  • 9.
    6. Variable isCase-sensitive. Eg. (age, Age, and AGE are three different variables) 7. Avoid using reserved keywords: Eg: Avoid using words like: for, if, else, while, def, print, or , not, and int, float, string etc
  • 10.
    HERE ARE SOMEEXAMPLES OF VALID VARIABLE NAMES: • myVariable • _privateVar • counter123 • school_name
  • 11.
    HERE ARE SOMEEXAMPLES OF INVALID VARIABLE NAMES: • 123variable (starts with a number) • @special (contains a special character) • for (uses a reserved keyword) • Stu Name (Space in the mddle)
  • 12.
    • When thevariable name is taken, you need to put something in the variable. The format is as follows: •= means not the equal sign in mathematics, but the assigned symbol, which means to save the value on the right to the variable on the left. ASSIGNING VALUES TO VARIABLES number = 9
  • 13.
    Output Variables The Pythonprint statement is often used to output variables. To combine both text and a variable, Python uses the + character: x = "awesome" print("Python is " + x) You can also use the + character to add a variable to another variable: x = "Python is " y = "awesome" z = x + y print(z) x=("Python is") y=("awesome") print(x,y)
  • 14.
    WHY WE USEVARIABLES IN PYTHON CODING? Storage: Variables store data like numbers or text during program run. Reuse: You can use data stored in variables again and again.  Manipulation: It helps to change the data easily. Readability: Variables give data meaningful names for clear code.
  • 15.
  • 16.
  • 17.
    Which is incorrectVariables as per guidelines? A. counter123 B. _privateVar D. Stu name C. school_name
  • 18.
    Which is thecorrect way to declare a variable in Python? B. NAME =Puja12 A. 12name = Puja D. -name=puja C. #Puja=name a) variable_name = value b) b) value = variable_name c) value = 123 d) value123 = 123
  • 19.
  • 20.
  • 21.
  • 22.
    Home Try next time, You can do it! Continue