Python practical
Python practical
CLASS IX
1. Practical no. 1
Source code
Print(“Personal information”)
Print(“Name: “, Name)
Print(“Father's name: “, Father's name)
Print(“Class: “, Class)
Print(“School name: “, School name)
#output
Personal information
Name: Mohan
Father's name: Rohan
Class: IX D
School name: Army Public School, PRTC
2. Practical no. 2
Source code
a=int(input(“enter a value="))
For i in range (1,a):
Print(“*”*1)
#output
Enter a value= 5
*
**
***
****
3. Practical no. 3
Source code
a=7
Sq.=a**2
Print(“The square is=”,Sq.)
#output
The square is= 49
4. Practical no. 4
Source code
A=15
B=20
Sum=A+B
Print(“the sum is=”,Sum)
#output
The sum is= 35
5. Practical no. 5
Source code
l= int(input(“enter length=”))
m=l*1000
Print(“the length in meters is=”,m)
#output
Enter length= 2
The length in metres is=2000m
6. Practical no. 6
Source code
For i in range (1,6):
Print(f “ 5 x {i} = { 5 * i }” )
#output
5x1=5
5x2=10
5x3=15
5x4=20
5x5=25
7. Practical no. 7
Source code
P=2000
R=4.5
T=10
SI=(P*R*T)/100
Print(“the simple interest is=”,SI)
#output
The simple interest is= 900
8. Practical no. 8
Source code
l=int(input(“enter length=”))
b=int(input(“enter breadth”))
Area=l*b
Print(“area=”,Area)
Perimeter=2*(l+b)
Print(“perimeter=”,Perimeter)
#output
Enter length= 4
Enter breadth= 2
Area= 6
Perimeter= 10
9. Practical no. 9
Source code
b=int(input(“enter base=”))
h=int(input(“enter height=”))
Area=1/2*b*h
Print(“the area of triangle=”, Area)
#output
Enter base= 2
Enter height= 6
The area of rectangle= 6
#output
Enter marks=39
Enter marks=32
Enter marks=35
The average is= 82.6666666667