Day 5 Python
Day 5 Python
How to be successful in python?
To practice and practice.
Programming using variables
What is variable?
Something that represents some value, but value can be changed.
<syntax o declare variables>
<variablename> = <value>
Example 1:
a = 10
b = 90123.098132
x = "Rad"
Types of values
1. Numerical value
Any number that doesn't have decimal and fractional part is called numerical value.
Example of numerical value:
-10
-20
7
3089013289312
-921831
Float
A number which ahs fractional and decimal part is floating value. Example of floating value:
-1.21
-3.11
939.11
0839012.391028
1000.1
String values
Collection of characters which encloses with the double quotes or single quotes in python. Example of string value:
"SAM"
"CAN)))!@(((*"
"POIU"
" " - this is known as empty string and still considered a string due to it being enclosed with double quotes.
Program 1 - write python program to store person name
1. Design with O/P
-------------------
| name ="whatever name you put here"
|
|print(name)
2. Program
name="any name"
print(name)
o/p
----
any name
Program 2 - Write a python program to store person name and age
1. Design with O/P
-------------------
| name = "name"
| age = "age"
| print(name)
|print(age)
Step 2 - Program
name = "name"
age = "age"
print(name)
print(age)
------------
Out/Put
----------
name
age
3. Write a python program to store a employee information employee number, name, and salary into 3 vars, eno ename, and esal.
Step 1 Design with the O/P
----------------
| eno = "9876543210"
|ename = "name"
| esal = "1234567890"
|print("Employee number is:",eno)
|print("Employee name is:",ename)
|print("Employee salary is:",esal)
Step 2 -> Program
| eno = "9876543210"
|ename = "name"
| esal = "1234567890"
|print("Employee number is:",eno)
|print("Employee name is:",ename)
|print("Employee salary is:",esal)
Homework - Write python program to store 3 subject marks, 80, 90, 100 into three variables that are M1, M2, M3. Calculate the total marks. Store into one variable called totmarks and calculate average marks store into another variable into another variable called avgmarks. Print the totalmarks and avgmarks with the help of message and variable.