Important QnA Histogram for Class 12 IP which is part of Chapter 3 Plotting with Pyplot. So here we go!
Topics Covered
Imortant QnA Histogram for Class 12 IP – Objective type questions (1 Mark)
Fill in the blanks, MCQs and True/False
[1] A __________ is a tool that summarize discrete or continuous data.
–> Histogram
[2] The numerical data shown by the number of data points that fall within a particular range is called _______.
–> bins
[3] A histogram is a similar to a vertical bar graph. [True/False]
[4] Which of the following data can be shown by histogram?
a) The quantity like weight, height, time
b) The categories
c) The uncountable data
d) All of these
[5] The histogram was introduced by _________
–> Karl Pearson
[6] A ______ function is used to create histogram.
–> hist()
[7] How many parameters a hist() function can have?
a) 2
b) 3
c) 4
d) 5
[8] A _______ is a boolean parameter of hist() funtion which is by default False.
–> cumulative
[9]A _____ parameter is just a number or series or arrays to be plotted on histogram.
–> x
[10] Which of the following is traditional bar-type histogram?
a) x
b) bins
c) histtype
d) orientation
[11] Which of the following parameter have values like horizontal or vertical?
a) x
b) bins
c) histtype
d) orientation
[12] Which of the following is the correct statement to create a histogram with ndarray x and bins value 30?
a) hist(x,bins:30)
b) hist(x,bins=30)
c) hist(x,bins-30)
d) hist(x,bins,30)
[13] A ________ value should be specified to histtype to generate a lineplot that is by default unfilled.
–> step
[14]You cannot create horizontal stacked histogram. (True/False)
[15] Which of the following is correct to generate horizontal stacked histogram?
a) hist([x,y], histtype=’barstacked’, orientation = ‘horizontal’)
b) hist([x,y], histtype=’horizontal’, orientation=’barstacked’)
c) b) hist([x,y], histtype=’horizontal’, orientation=’landscape’)
d) None of these
Histogram for Class 12 IP – Conceptual Descriptive/Subjective Questions
[1] Describe the histogram. How to plot data on histogram?
Ans.: A histogram is quite similar to a vertical bar graph with no space in between vertical bars. When you have data which has data points fall between a particular range, you can use the histogram to visualize this data. It is helpful to display statistical data or data inserted in measurable quantities. For ex. Marks, scores, units etc. It was first introduced by Karl Pearson.
[2] Explain hist() function in detailed.
Ans.:
To create histogram in python hist() function is used. The syntax of hist() function is like this:
matplotlib.pyplot.hist(x, bins=value,cumulative=bool_val, histtype=type, align=alignment, orientation=orientation)
where,
x: It is list to be plotted on histogram
bins: bins can be integer number computed with + 1 or generated by default.
cumulative: It is a boolean value i.e. either True or False. If provided True then bins are calculated where each bin gives the counts in that bin plus all bins for smaller values. The last bin gives total number of data points. The default value is false.
hisstype: It is an option parameter. It can be any one of these:
- bar: Bar type histogram, it arranges data side by side if given data is multiple. It is by default histtype.
- barstacked: When multiple data are stacked on top of each other
- step: Generates a lineplot that is by default unfilled
- stepfilled: Generates a lineplot that is by default filled
orientation: It can be used for bar – type histogram
[3] Clarify the situations when you need to use bar() charts and when you need to use hist() chart?
Ans.: The bar() chart is usually used to plot data to compare and plot them on a singular bar. Histogram is used to specify the range and plot them on figure according to the range.
[4]What is the significance of the cumulative histogram? Elaborate your answer with an example.
Ans.: The cumulative histogram shows the histogram from minimum range to higher range in ascending order.
[5] How to change the edgecolor and color of histogram bar?
Ans.: To change the edgecolor, python provides edgecolor parameter inside hist() function. To change the color of histogram facecolor parameter is required.
[6] How to save the histogram as image?
Ans.: To save the histogram as image savefig() function is used. Specify the path for the file for saving the figure.
Histogram for Class 12 IP – Application-based questions
[1] Write code to plot following data on histogram:
24,17,14,22,25,26,38,42,24,12,28,19,32,21,35,28,21,31,18,19
import matplotlib.pyplot as mp
l=[24,17,14,22,25,26,38,42,24,12,28,19,32,21,35,28,21,31,18,19]
mp.hist(l)
mp.show()
[2] Generate random numbers from 1 to 70 and plot it on the histogram. Change the outline color to black and the bar color should be yellow.
import matplotlib.pyplot as m
import numpy as np
x=np.random.randn(70)
m.hist(x,20,edgecolor="black",facecolor="yellow")
m.show()
[3] Display the above data in cumulative mode on histogram.
import matplotlib.pyplot as m
import numpy as np
x=np.random.randn(70)
m.hist(x,20,cumulative= True, edgecolor="black",facecolor="yellow")
m.show()
[4] Write python code to create histogram based on given data:
rcb: 78,63,49,41,68,101,56,79,68,96
mi: 45,85,98,102,42,50,43,48,63,39
import matplotlib.pyplot as m
rcb=[78,63,49,41,68,101,56,79,68,96]
mi=[45,85,98,102,42,50,43,48,63,39]
m.hist([rcb,mi],cumulative='true')
m.show()
[5] Draw histogram for the following code:
import matplotlib.pyplot as m
english=[77,66,88,99,55,44,33,79,68,83]
maths=[56,89,70,50,60,65,90,80,47,82]
m.hist([english,maths], orientation='horizontal')
m.show()
Thank you for your visit and for reading this article Important QnA Histogram for Class 12 IP.
Share with your friends and classmates. Feel free to ask your doubt in the comment section as well.
Unlock following link to get the pdf solution.
Watch this video for more understanding.
Share this video with your friends and in your circle. If you have any doubts or queries feel free to write in the comment section.
Your suggestions/views/feedbacks are always welcome. Write your views/suggestions/feedbacks in the comment section to improve our contents.
If you have any other concern related to out blog you can use our contact us section to inform us. We will try to resolve the concern.
Thank you for visit.