Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

PYTHON PRACTICAL

NOTES uwu
(ARITHMETIC
OPERATORS)
Basic operators:
print(5+6)
- ADDITION
print(6-5)
- SUBTRACTION
print(5*6)
- MULTIPLY
print(5**2)
-5 RAISED TO THE POWER 2
print(16/5)
- 16 DIVIDED BY 5
print(16//5)
- INTEGER VALUE OF 16 DIVIDED BY 5
print(16%5)
- REMAINDER OF 16 DIVIDED BY 5
SUCCESOR/PREDESSOR : ANY INTEGER
NUMBER
uwu = int(input("enter a number: "))
print("successor" , uwu + 1 )
print("predecessor" , uwu - 1 )
SUCCESSOR/PREDECESSOR : FIXED
NUMBER
x=5
print("successor" , x+1)
print("predecessor" , x-1)
HOW TO FIND AVERAGE? Any integer
value.
Science = int(input("Enter your marks of
sci:"))
SST = int(input("Enter your marks of sst:"))
English = int(input("Enter your marks of
eng:"))
Hindi = int(input("Enter your marks of
hindi:"))
Maths = int(input("Enter your marks of
math:"))
Total_Marks = Science + SST + English +
Hindi + Maths
print("Total Marks" , Total_Marks)
Average_of_marks = Total_Marks/5
print("Average of marks:" ,
Average_of_marks )
FOR FIXED VALUES –
Science = 40
SST = 20
English = 40
Hindi = 20
Maths = 30
Total_Marks = Science + SST + English +
Hindi + Maths
print("Total Marks" , Total_Marks)
Average_of_marks = Total_Marks/5
print("Average of marks:" ,
Average_of_marks )
WAP that accepts two integer variables
using input commands and displays its
difference.
Method 1 –
uwu = int(input("write a number: "))
lala = int(input("Write another number: "))
print("difference of these 2 numbers:" ,
uwu-lala )
Method 2 –
uwu = int(input("write a number: "))
lala = int(input("Write another number: "))
difference_of_numbers = uwu - lala
print("difference of these 2 numbers:" ,
difference_of_numbers )
WAP that accepts two integer variables
using input commands and finds the
reminder after the division.

uwu = int(input("number 1: "))


uwu2 = int(input("number 2: "))
print("remainder after division:" , uwu
%uwu2)
*has 2 methods like the previous
question*
In these types of questions, you can first
take a variable for the operation or do it
directly during printing. It is up to you.
Both of them are correct.
If you have to get the variable in decimal
form, then use the code –
float(input(“enter the number: “)) (same
way for other programs)

WAP that converts temperature in celsius


to fahrenheit.
Celsius to Fahrenheit formula = multiply by 1.8 (or
9/5) and add 32.

celcius = int(input("enter the


temperature: "))
farheniet = celcius*1.8+32
print("temperature in
farheniet: " , farheniet )
6. WAP that accepts the length and
breadth of a rectangle using the input
command and finds its perimeter and
area.
length = int(input("length of the rectangle:
" ))
breadth = int(input("Breadth of the
rectangle: "))
Area_of_rectangle = length*breadth
print("Area of rectangle: " ,
Area_of_rectangle , "square cm")
Perimeter_of_rectangle =
2*(length+breadth)
print("Perimeter of rectangle: " ,
Perimeter_of_rectangle , "cm")

You might also like