0% found this document useful (0 votes)
24 views4 pages

Class X - Practical File 2024-24

Uploaded by

lojid24909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Class X - Practical File 2024-24

Uploaded by

lojid24909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Write a program to add the elements of the two lists.

# initializing lists
list1 = [1, 3, 4, 6, 8]
list2 = [4, 5, 6, 2, 10]

# printing original lists


print ("Original list 1 : " ,list1)
print ("Original list 2 : " ,list2)

# add two list


res_list = []
for i in range(0, len(list1)):
res_list.append(list1[i] + list2[i])

# printing resultant list


print ("Resultant list is :" ,res_list)

OUTPUT:
Original list 1 : [1, 3, 4, 6, 8]
Original list 2 : [4, 5, 6, 2, 10]
Resultant list is : [5, 8, 10, 8, 18]

2. Write a program to calculate mean, median and mode using Numpy.


import numpy as np
data = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 97, 98,99,100]
mean_value = np.mean(data)
print(“Mean: “,mean_value)

OUTPUT:
Mean: 6.50

import numpy as np
data = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 97, 98, 99, 100]
median_value = np.median(data)
print(“Median: “,median_value)

OUTPUT:
Median: 21.17

import numpy as np
data = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 97, 98, 99, 100]
mode_value = np.mode(data)
print(“Mode: “,mode_value)

3. Write a program to display a scatter chart.


import matplotlib.pyplot as plt
x =[5, 7, 8, 7, 2, 17, 2, 9,
4, 11, 12, 9, 6]

y =[99, 86, 87, 88, 100, 86,


103, 87, 94, 78, 77, 85, 86]

plt.scatter(x, y, c ="blue")

# To show the plot


plt.show()

OUTPUT:

4. Read csv file saved in your system and display 10 rows.


import pandas as pd

import numpy as np

users = {'Name': ['Amit', 'Cody', 'Drew'],

'Age': [20,21,25]}

#create DataFrame

df = pd.DataFrame(users, columns=['Name','Age'])

print("Original DataFrame:")

print(df)

print('Data from Users.csv:')


df.to_csv('Users.csv', sep='\t', index=False,header=True)

new_df = pd.read_csv('Users.csv')

print(new_df)

OUTPUT:

Original DataFrame:
Name Age
0 Amit 20
1 Cody 21
2 Drew 25
Data from Users.csv:
Name\tAge
0 Amit\t20
1 Cody\t21
2 Drew\t25
5. Write a program to read an image and display using Python

#import cv2, numpy and matplotlib libraries


import cv2
import numpy as np
import matplotlib.pyplot as plt
img=cv2.imread(r"C:\Users\RISHI\Desktop\image1.jpg")
#Displaying image using plt.imshow() method
plt.imshow(img)

#hold the window


plt.waitforbuttonpress()
plt.close('all')

OUTPUT:

You might also like