Page 337 - AI Ver 1.0 Class 10
P. 337
[0. 0. 0.]
[0. 0. 0.]]
10. Using Matplotlib and the given data, plot a bar chart:
No of people voted = [23,45,31,40,35]
Area covered = [‘a1’,’a2’,’a3’,’a4’,’a5’]
Ans. Program:
import matplotlib.pyplot as plt
No_of_people_voted = [23,45,31,40,35]
plt.bar(['a1','a2','a3','a4','a5'], No_of_people_voted)
plt.title('Bar Chart')
plt.xlabel('Area covered')
plt.ylabel('No of people voted')
plt.show()
Output:
Bar Chart
40
No. of people voted 30
20
10
0
a1 a2 a3 a4 a5
Area covered
11. Using Matplotlib and the given data, plot a line chart:
x_axis = [3,4,6,2,8]
y_axis = [9,10,8,7,6]
Ans. Program:
import matplotlib.pyplot as plt
import numpy as np
x = np.array([3,4,6,2,8])
y = np.array([9,10,8,7,6])
plt.plot(x, y)
plt.show()
Python Practical Questions 335

