Class X Practical-2025 - Jupyter Notebook
Class X Practical-2025 - Jupyter Notebook
NumPy is a powerful open-source scientific package that stands for Numerical Python. It uses
mathematical and logical operations for handling large datasets through n-dimensional arrays
that speeds up data processing.
In [ ]: import numpy as np
In [ ]: a=np.ones((3,4))
print(a)
In [ ]: a=np.zeros((4,5))
print(a)
In [ ]: a=np.full((4,5),7)
print(a)
In [ ]: a=np.eye(4,4)
print(a)
Statistical Functions
In [ ]: #maximum value in the element of the array
print(c.max())
In [ ]: # median- gives middle value of array (first sorts and then gives middle value
m=np.array([4,2,3,9,7]) #as values are odd so gives centre value
y=np.median(m)
print(y)
In [ ]: m=np.array([4,2,3,6,9,7])
y=np.median(m) # as values are even so gives average of middle 2
print(y)
Pandas
Pandas is an open-source python library used for data manipulation and analysis
In [ ]: import pandas as pd
In [ ]: #Isolate a column
d1["Recovered"]
In [ ]: #Isolate rows
d1[3:10]
Data Visualisaton
In [ ]: #Bar Plot
x=np.array(["Rohan", "Aarti", "Suniti", "Raghav", "Anshika"])
y=np.array([145,367,235,463,486])
plt.bar(x,y)
plt.show()
In [ ]: #Bar Plot
x=np.array(["Rohan", "Aarti", "Suniti", "Raghav", "Anshika"])
y=np.array([145,367,235,463,486])
plt.bar(x,y,color=["red","green","Blue","Orange","yellow"],edgecolor=['black',
plt.title("Result")
plt.xlabel("Names of the Students")
plt.ylabel("Marks")
plt.show()
In [ ]: #Scatter Plot
x=np.array(["Rohan", "Aarti", "Suniti", "Raghav", "Anshika"])
y=np.array([145,367,235,463,486])
plt.scatter(x,y)
plt.show()
In [ ]: #Line Plot
x=np.array(["Rohan", "Aarti", "Suniti", "Raghav", "Anshika"])
y=np.array([145,367,235,463,486])
plt.plot(x,y)
plt.show()
In [ ]: #Line Plot
x=np.array(["Rohan", "Aarti", "Suniti", "Raghav", "Anshika"])
y=np.array([145,367,235,463,486])
plt.plot(x,y,marker="*",ms=10, mec="red",mfc="green",linewidth=4,linestyle="do
plt.title("Result Comparison")
plt.xlabel("Name of the Students")
plt.ylabel("Marks")
plt.show()
In [ ]: #Pie Chart
m=np.array(['Soham','Raghav','Riya','Arjun'])
n=np.array([78,45,89,67])
plt.pie(y,labels=x)
plt.show()
In [ ]: #Histogram
a=[45,35,78,46,25,23,57,85,34,90,45,35,64,45]
plt.hist(a)
plt.show()
Image Processing
OpenCV represents the images in BGR as opposed to the RGB we expect. Since it is in the
reverse order, you tend to see the blue color in images. We will use the following code for
converting from BGR to RGB
In [ ]: # Resizing an Image
resized = cv2.resize(img, (360,640))
plt.imshow(cv2.cvtColor(resized, cv2.COLOR_BGR2RGB))
print(resized.shape)
In [ ]: # Flip an Image
img5=cv2.flip(img,0) # 0 - flip vertical, 1-
plt.imshow(img5)
In [ ]: imgcropped=img[500:650,200:900]
plt.imshow(imgcropped)
In [ ]: #Edge Detection
img9=cv2.imread('shah.jpg')
edge=cv2.Canny(img9, 200,200)
plt.imshow(edge)