VSA - Very Short Answer Question (For 1 Mark) : Chapter - Data Visualization
VSA - Very Short Answer Question (For 1 Mark) : Chapter - Data Visualization
Q.10 Mr.Sanjay wants to plot a bar graph for the given set of values of subjects on x-axis and
number of students who opted for that subject on y-axis.
Complete the code to perform the following operation
(i) to plot the bar graph in statement 1
(ii) to display the graph in statement 2
x = [‘HINDI’, ‘ENGLISH’, ‘SCIENCE’ , ‘SST’]
y=[10,20,30,40]
____________ # statement 1
____________# statement 2
Ans. (i) plt.bar(x,y)
(iii) plt.show( )
Ans. c.legend()
Q.15 Using Python Matplotlib _________ can be used to count how many values fall
into each interval
a. line plot
b. bar graph
c. histogram
Ans. c. histogram
Q.16 Mr. Harry wants to draw a line chart using a list of elements named LIST. Complete the
code to perform the following operations :
(i) To plot a line chart using the given LIST
(ii) To give a y-axis label to the line chart named sample number.
import matplotlib.pyplot as PLINE
LIST=[10,20,30,40,50,60]
______________ #statement 1
_____________ #statement 2
Ans. (i) PLINE.plot(LIST)
(i) PLINE.ylabel(“Sample number”)
Q.19 _____ are specified as consecutive, non overlapping intervals of a variable, mainly used
in histograms.
i) Series
ii) Bins
iii) Gaps
iv) Axis
Q.1 Consider the following graph. Write the code to plot it.
Ans.
import matplotlib.pyplot as plt
a = [0,1,2,3,4,5]
b = [10,31,26,24,20]
plt.plot(a,b)
plt.show()
Q.2 Write code to draw the following bar graph representing the number of students in each
class.
Ans.
import matplotlib.pyplot as plt
Classes = ['VII','VIII','IX','X']
Students = [40,45,35,44]
plt.barh(classes, students)
plt.show()
Ans.
Ans.
import matplotlib.pyplot as p
x=["Sony","Star","SAB","Zee"]
y=[60,40,55,35]
p.plot(x,y, linestyle=":")
p.title('TRP of various channels')
p.xlabel('Name of Channel',fontsize="15",color="green")
p.ylabel('TRP',fontsize="15",color="green")
p.show()
Q.6 Consider the following graph. Write a program in python to draw it along with proper
labeling of X-axis, Y-axis and Title for the line Chart of your choice.
Ans.
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-2, 2,50)
y=x*x
plt.plot(x,y)
plt.title('Y = x * x')
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.show()
Q.7 Consider the following graph. Write a program in python to draw it. (Height of Bars are
10,1,0,33,6,8)
Ans.
import numpy as np
import matplotlib.pyplot as plt
plt.hist([0,10,20,30,40,50],bins=[0,10,20,30,40,50,60],weights=[10,1,0,33,6,8],edgecolor='yello
w')
plt.title('Histogram of Student Data')
plt.xlabel('value')
plt.ylabel('Frequency')
plt.show()