Page 339 - AI Ver 1.0 Class 10
P. 339
Height = [4.5,5.2,4.1,3.5,5]
plt.scatter(Height, Weight, c='blue')
plt.title('Scatter plot')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
Output:
Scatter plot
55
50
Weight 45
40
35
3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25
Height
14. Using NumPy package: Create an array of 5 marks and display the average of all marks.
Ans. Program:
import numpy as np
import statistics
a = np.array([95,90,49,71,80])
m = statistics.mean(a)
print("The average is: ", m)
Output:
The average is: 77
15. Create a list of distance travelled by a car in a week and calculate using statistics module:
• Mean • Median • Mode
Ans. Program:
import statistics
d = [95,90,49,71,90,100,55]
m1 = statistics.mean(d)
m2 = statistics.median(d)
m3 = statistics.mode(d)
print("The mean is: ", m1)
print("The median is: ", m2)
print("The mode is: ", m3)
Python Practical Questions 337

