0% found this document useful (0 votes)
277 views

VSA - Very Short Answer Question (For 1 Mark) : Chapter - Data Visualization

The document contains questions and answers about data visualization using Matplotlib and Python. It includes questions testing knowledge of basic Matplotlib concepts like plotting graphs, adding labels and titles, importing Matplotlib, and different types of charts like bar graphs, histograms, and line charts. Short answer questions provide code samples to plot specific graphs. Overall, the document covers fundamental Matplotlib concepts and usage through multiple choice and short answer questions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
277 views

VSA - Very Short Answer Question (For 1 Mark) : Chapter - Data Visualization

The document contains questions and answers about data visualization using Matplotlib and Python. It includes questions testing knowledge of basic Matplotlib concepts like plotting graphs, adding labels and titles, importing Matplotlib, and different types of charts like bar graphs, histograms, and line charts. Short answer questions provide code samples to plot specific graphs. Overall, the document covers fundamental Matplotlib concepts and usage through multiple choice and short answer questions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CHAPTER – DATA VISUALIZATION

VSA – Very Short Answer Question (for 1 Mark)


Q.1 The matplotlib Python library developed by ____________
Ans. John Hunter

Q.2 _________ is amodule in the matplotlib package.


Ans. Pyplot

Q.3 The matplotlib API is imported using the ___________.


Ans. standard convention

Q.4 The _____ is bounding box with ticks and labels.


Ans. axes

Q.5 The _____ can be plotted verticall or horizontally.


Ans. bar chart

Q.6 Histograms are used to show a/an ____________.


Ans. distribution

Q.7 To add a tittle in a chart, ____________ function is used.


Ans. tittle()

Q.8 A bar graph uses bars to compare data among ________.


Ans. different categories.

Q.9 What is Pylab?


Ans. Pylab is a package that combine numpy,scipy ad matplotlib into a single namespace.

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( )

Q.11 How to import matplotlib?


Ans. form matplotlib import pyplot as plt.

Q.12 Which of the following is not a valid chart type?


a. line
b. bar
c. histogram
d. statistical
Ans. d.statistical

Q.13 The command used to show legends is


a. display()
b. show()
c. legend()
d. legends()

Ans. c.legend()

Q.14 The command used to give a heading to a graph is _________


a. plt.show()
b. plt.plot()
c. plt.xlabel()
d. plt.title()
Ans. d.plt.title()

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.17 In matplotlib, what is ticks?


Ans. A standard graph shows the marks on the axis, in matplotlib library, it is called ticks.

Q.18 What is the use of label in plotting?


Ans. Label is used to add labels or names to respective x and y axis.

Q.19 _____ are specified as consecutive, non overlapping intervals of a variable, mainly used
in histograms.
i) Series
ii) Bins
iii) Gaps
iv) Axis

Ans. ii) Bins


Q.20 Assuming that a line chart is plotted on x and y axis, write the command to give title as
‘New Graph’ using Plt object

Ans. Plt.title(‘New Graph’)

SA – Short Answer Question (for 3 Marks)

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()

Q. 3 What will be the output of the follwing code ?

From matplotlib import pyplot as plt


X=[4,8,3]
Y=[1,6,9]
plt.plot(X,Y)
plt.title(‘Details)
plt.ylabel(‘Y axis’)
plt.xlabel(‘X axis’)
plt.show( )

Ans.

Q.4 Write the output graph of :


import matplotlib.pyplot as p
x=[2,3,4,5,6,7]
y=[1,2,3,4,5,6]
p.plot(x,y)
p.show()
Ans.
Q.5 Write code to plot a line graph showing the relation between channel name and its TRP
rating ( 4 channels). Include the titles and formatting of your choice. The font size of the x and y
labels should be 15 and font color should be green

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()

CHAPTER – DATA BASE QUERY USING SQL


VSA – Very Short Answer Question (for 1 Mark)

You might also like