STD-X Pracical List
STD-X Pracical List
Activity1:ToprintpersonalinformationlikeName,Father’sName,Class,SchoolName.
Code:
print("My Name is:","Rajesh Kumar")
print("MyFatherNameis:","RakeshKumar")
print("My class is 10-A")
print("MySchoolis","PMSHRIKENDRIYAVIDYALAYA")
o/p:
MyNameis:RajeshKumar
MyFatherNameis:RakeshKumar My
class is 10-A
MySchoolisPMSHRIKENDRIYA VIDYALAYA
Activity2:WriteaPythoncodetocalculateSimpleInterestiftheprinciple_amount= 2000
rate_of_interest = 8 time = 10
Code:
P=2000
T=10
R=8
SI=(P*T*R)/100 #calculatessimple interest
print"SimpleInterestis",SI)
o/p:
SimpleInterestis1600.0
Activity3:WriteaPythoncodetocalculateAreaofatrianglewithBaseandHeight Code:
B=int(input("EnterBaseofarectangle")) #readingbasevalueoftherectangle
H=int(input("EnterHeightofarectangle"))#readingheightoftherectangle
print("Areaofarectangleis",0.5*B*H) #displaysareoftherectangle
1
o/p:
Enter Base of a rectangle5
EnterHeightofarectangle4
Area of a rectangle is 10.0
Activity4:WriteaPythoncodetocheckwhetherapersoniseligibletovoteornot.
Code:
Age=int(input("Enterperson’sage"))
if Age>=18: #checkingthecondition
print("Person is Eligible to vote")
else:
print("PersonisnotEligibleto vote")
o/p:
Enterperson’sage21
PersonisEligibletovote
Activity5:WriteaPythoncodetoprintsumoffirst10naturalnumbers. Code:
S=0
foriin range(1,11):
S=S+i
print("Sumoffirst10naturalnumbersis",S)
o/p:
Sumoffirst10naturalnumbersis55
Activity6:WriteaPythoncodetoassigntheGradebasedonthegivenpercentage: Code:
per=float(input("Enterstudentspercentage"))
if per>=90: #checking the condition
grade="A" # assigning grade
elif per>=70:
2
grade="B"
elif per>=50:
grade="C"
elif per>=33:
grade="D"
else:
grade="E"
print("Perntageis",per)
print("Grade is",grade)
o/p: Enterstudentspercentage89
Perntage is 89.0
Gradeis B
Activity7:Writeaprogramtocreatealistanddisplaylistelements.
Code:
l=[ ]
n=int(input("Enterlengthofthelist"))
for i in range(n):
a=eval(input("Enterlistelement"))
l.append(a)
print("Createdlistis",l)
o/p:
Enterlengthofthelist5
Enter list element10
Enter list element20.5
Enter list element45
Enter list element78
Enter list element23
3
Created list is: [10,20.5,45,78, 23]
Activity8:Writeaprogramtoaddtheelementsofthetwolists.
Code:
l1=[20,30,40]
l2=[30,50,10]
l3=l1+l2
print("Additionof",l1,"and",l2,"is",l3)
o/p:
Additionof[20,30,40]and[30,50,10]is[20,30,40,30,50,10]
Activity9:Writeaprogramtocalculatemean,medianandmodeusingNumpy
Code:
import numpy as np
importstatisticsasst
l=[30,20,50,60,20]
l1=np.array(l)
print("Meanof",l1,"is",st.mean(l1))
print("Medianof",l1,"is",st.median(l1))
print("Modeof",l1,"is",st.mode(l1))
o/p:
Meanof[3020506020]is36
Medianof[3020506020]is30
Modeof [30205060 20]is 20
Activity10:Writeaprogramtodisplaylinechartfrom(2,5)to(9,10).
Code:
importmatplotlib.pyplotasplt
4
x=(2,9)
y=(5,10)
plt.plot(x,y)
plt.title("Linechart")
plt.show()
o/p:
Activity11:Writeaprogramtodisplayascatterchartforthefollowingpoints(2,5),
(9,10),(8,3),(5,7),(6,18).
Code:
importmatplotlib.pyplotasplt x=[2,9,8,5,6]
y=[5,10,3,7,18]
plt.scatter(x,y)
plt.title("Linechart")
plt.show()
o/p:
Activity 12: Write a program to display bar chart for the following data with appropriate
titles:
Subjects=[“Eng”,”Sci”,”Soc”,”Maths”,”AI”]
Marks=[89,87,78,90,99]
Code:
5
import matplotlib.pyplot as plt
Sub=["Eng","Sci","Soc","Maths","AI"]
Marks=[89,87,78,90,99]
plt.bar(Sub,Marks)
plt.title("Term-1Performance")
plt.xlabel("Subjects")
plt.ylabel("Marks")
plt.show()
0/p:
Activity 13: Write a program to display histogram for the following data with appropriate
titles:
stu=[5,14,17,23,34,50,20,34,24,56,45,34,23,34,32,9,8,22,24,34,55,66,23,23]
Code:
import matplotlib.pyplot as plt
stu=[5,14,17,23,34,50,20,34,24,56,45,34,23,34,32,9,8,22,24,34,55,66,23,23]
6
plt.hist(stu,bins=[0,10,20,30,40,
50,60,70]) plt.xlabel("Marks")
plt.ylabel("No.Of Students")
plt.title("MarksObtainedbyth
eStudents") plt.show()
o/p: