Python Variable for the students who started their python.pptx

DurgaPrasad774801 38 views 22 slides Jun 28, 2024
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

Variables in Python.
This contents helps the beginners to understand the concept of variable


Slide Content

Topic: Variable in Python

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: Print Result

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 Do not use any special character like @,# %! Use descriptive names: Use names that describe what the variable represents. Variable is Case-sensitive. Eg. (age, Age, and AGE are three different variables) 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.

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✅

Variable will not have space in the middle. Eg. Do not use any special characters like Eg @,# %! 5. Variables should be short and meaningful/descriptive 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 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 assign ed 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 ) OR OR

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. 12n ame = Puja D. -name =puja C . # Puja=name variable_name = value 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