class X AI python programs (1)
class X AI python programs (1)
Activity 1: Write a Python code to calculate Simple Interest if the principle_amount = 2000
rate_of_interest = 8 time = 10
P=2000
T=10
R=8
SI=(P*T*R)/100
o/p:
Activity 2: Write a Python code to calculate Area of a triangle with Base and Height
o/p:
Activity 3: Write a Python code to check whether a person is eligible to vote or not.
if Age>=18:
else:
o/p:
S=0
for i in range(1,11):
S=S+i
o/p:
l=[]
for i in range(n):
l.append(a)
o/p:
l1=[20,30,40]
l2=[30,50,10]
l3=l1+l2
print("Addition of",l1,"and",l2,"is",l3)
o/p:
Addition of [20, 30, 40] and [30, 50, 10] is [20, 30, 40, 30, 50, 10]
Activity 7: Write a program to calculate mean, median and mode using Numpy
import numpy as np
import statistics as st
l=[30,20,50,60,20]
l1=np.array(l)
print("Mean of",l1,"is",st.mean(l1))
print("Median of",l1,"is",st.median(l1))
print("Mode of",l1,"is",st.mode(l1))
o/p:
x=(2,9)
y=(5,10)
plt.plot(x,y)
plt.title("Line chart")
plt.show()
l1=[20,30,40]
l2=[30,50,10]
l3=l1+l2
print("Addition of",l1,"and",l2,"is",l3)
o/p:
Addition of [20, 30, 40] and [30, 50, 10] is [20, 30, 40, 30, 50, 10]
Activity 7: Write a program to calculate mean, median and mode using Numpy
import numpy as np
import statistics as st
l=[30,20,50,60,20]
l1=np.array(l)
print("Mean of",l1,"is",st.mean(l1))
print("Median of",l1,"is",st.median(l1))
print("Mode of",l1,"is",st.mode(l1))
o/p:
Mean of [30 20 50 60 20] is 36
x=(2,9)
y=(5,10)
plt.plot(x,y)
plt.title("Line chart")
plt.show()
Activity 9: Write a program to display a scatter chart for the following points (2,5), (9,10),(8,3),(5,7),
(6,18).
x=[2,9,8,5,6]
y=[5,10,3,7,18]
plt.scatter(x,y)
plt.title("Line chart")
plt.show()
op:
Activity 10: 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]
Sub=["Eng","Sci","Soc","Maths","AI"]
Marks=[89,87,78,90,99]
plt.bar(Sub,Marks)
plt.title("Term-1 Performance")
plt.xlabel("Subjects")
plt.ylabel("Marks")
plt.show()
0/p:
Activity 11: Read CSV file saved in your system and display 5 rows
import pandas as pd
df=pd.read_csv(r"C:\Users\ADMIN\Desktop\abc.csv",nrows=10)
print(df)
o/p:
0 1 HARI 67
1 2 RAMESH 89
2 3 SOMESH 56
3 4 RAJESH 78
4 5 BHIMESH 45
Activity 12: Read CSV file saved in your system and display its information
import pandas as pd
df=pd.read_csv(r"C:\Users\ADMIN\Desktop\abc.csv",nrows=10)
print(df)
o/p:
0 1 HARI 67
1 2 RAMESH 89
2 3 SOMESH 56
3 4 RAJESH 78
4 5 BHIMESH 45
5 6 SRIKANTH 67
6 7 SRINIVAS 89
7 8 SANDHYA 90
8 9 SADANA 56
9 10 RAJU 45
Activity 13: Write a program to read an image and display using Python
import cv2
img=cv2.imread("abc.jpg")
cv2.imshow('Image',img)
cv2.waitKey(0)
o/p:
Activity 14: Write a program to read an image and display image shape and size using Python
import cv2
img=cv2.imread(r"C:\Users\ADMIN\Desktop\abc.jpg")
cv2.imshow('myimg',img)
cv2.waitKey(0)
o/p:
The shape of the image is (148, 259, 3)