Practical Set 2 Answers
Practical Set 2 Answers
(v) df = df.drop(‘Mohan’)
Maths Science SST Total
Amit 100.0 100.0 60.00 260.00
Sudha 85.0 85.0 53.58 228.58
T5 75.6 98.6 56.60 230.80
B. Write a Python program to display the given Result
using a BAR CHART (3)
Maths Science SST
Amit 100 100.0 60.0
Mohan 95 100.0
57.48
Sudha 85 100.0
53.58
(i) Set the title of the graph as “Result Analysis”.
(ii) Display the legends.
(iii) Display the label of x axis to “Name” and y axis to
“Score”
Answer:
1import matplotlib.pyplot as plt
2import numpy as np
3
4Subject = ['Maths','Science', 'S.St']
5
6Amit = [100, 100.0, 60.0]
7Mohan = [95, 100.0, 57.48]
8Sudha = [85,100.0,53.58]
9
10x_axis = np.arange(len(Subject))
11
12plt.bar(x_axis - 0.25 , Amit, 0.25, label='Amit')
13plt.bar(x_axis, Mohan, 0.25, label='Mohan')
14plt.bar(x_axis + 0.25, Sudha,0.25, label='Sudha')
15
16plt.xticks(x_axis, Subject)
17
18plt.legend(loc =1)
19
20plt.xlabel("Name")
21plt.ylabel("Score")
22plt.title("Result Analysis")
23
24plt.show()
Output:
Fr
Co
So
Ba
Ba
1420