Matplotlib Bar Graph MCQs | 25 Practice Questions with Answers | CBSE Class 12 Informatics Practices (IP)
Class 12 · Informatics Practices
Matplotlib Bar Graph MCQs (25 Questions)
Practice these multiple-choice questions to strengthen your understanding of Matplotlib Bar Graphs. Click Show Answer to reveal the correct answer and explanation.
Q1. A bar graph is mainly used to:
A. Show trends over time
B. Compare different categories
C. Display frequency distribution
D. Store data
Show Answer
Answer: B. Compare different categories
Explanation: A bar graph is used to compare values across different categories using rectangular bars.
Q2. Which Matplotlib function is used to create a vertical bar graph?
A. plt.plot()
B. plt.bar()
C. plt.hist()
D. plt.barh()
Show Answer
Answer: B. plt.bar()
Explanation: The bar() function creates a vertical bar graph.
Q3. Which function is used to create a horizontal bar graph?
A. plt.plot()
B. plt.barh()
C. plt.hist()
D. plt.show()
Show Answer
Answer: B. plt.barh()
Explanation: The barh() function creates horizontal bars.
Q4. Which graph is best for comparing the marks obtained by students in different subjects?
A. Line Plot
B. Histogram
C. Bar Graph
D. Scatter Plot
Show Answer
Answer: C. Bar Graph
Explanation: A bar graph is ideal for comparing values across different categories such as subjects.
Q5. In a vertical bar graph, categories are usually shown on the:
A. Y-axis
B. X-axis
C. Both axes
D. Neither axis
Show Answer
Answer: B. X-axis
Explanation: Categories are generally placed on the X-axis, while their corresponding values are plotted on the Y-axis.
Q6. Which of the following is TRUE about a bar graph?
A. Bars have equal width.
B. Bars are separated by equal gaps.
C. It compares categories.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Bar graphs use equally spaced bars of equal width to compare categorical data.
Q7. Which graph is most suitable for comparing the sales of five different products?
A. Bar Graph
B. Histogram
C. Line Plot
D. Pie Chart
Show Answer
Answer: A. Bar Graph
Explanation: Bar graphs are designed for comparing values across different categories.
Q8. Which graph is generally preferred for categorical data?
A. Histogram
B. Bar Graph
C. Line Plot only
D. None of these
Show Answer
Answer: B. Bar Graph
Explanation: Bar graphs represent categorical data effectively.
Q9. Which statement creates a simple vertical bar graph?
A. plt.bar(x, y)
B. plt.plot(x, y)
C. plt.hist(x)
D. plt.barh(y)
Show Answer
Answer: A.
Explanation: The bar() function requires category labels and corresponding values.
Q10. Which statement creates a horizontal bar graph?
A. plt.bar(x, y)
B. plt.barh(x, y)
C. plt.plot(x, y)
D. plt.hist(y)
Show Answer
Answer: B.
Explanation: The barh() function is used for horizontal bar graphs.
Q11. Which graph would be most appropriate to compare the number of books issued by different school houses?
A. Bar Graph
B. Histogram
C. Line Plot
D. Scatter Plot
Show Answer
Answer: A.
Explanation: Since the data belongs to different categories (houses), a bar graph is the best choice.
Q12. Which graph is suitable for comparing the population of different cities?
A. Histogram
B. Bar Graph
C. Line Plot
D. Frequency Polygon
Show Answer
Answer: B.
Explanation: A bar graph compares values among different categories such as cities.
Q13. Which graph uses rectangular bars to represent values?
A. Line Plot
B. Bar Graph
C. Histogram
D. Scatter Plot
Show Answer
Answer: B.
Explanation: A bar graph uses separate rectangular bars to represent different categories.
Q14. Which graph is NOT generally used for showing continuous trends?
A. Line Plot
B. Bar Graph
C. Both A and B
D. None of these
Show Answer
Answer: B.
Explanation: Bar graphs compare categories rather than showing continuous trends.
Q15. Which statement about Matplotlib bar graphs is correct?
A. bar() creates vertical bars.
B. barh() creates horizontal bars.
C. Both are used to compare categories.
D. All of these.
Show Answer
Answer: D.
Explanation: Both bar() and barh() are used to compare categorical data.
Q16. A school wants to compare the number of students in Classes XI-A, XI-B, XI-C, and XI-D. Which graph is most suitable?
A. Line Plot
B. Histogram
C. Bar Graph
D. Scatter Plot
Show Answer
Answer: C. Bar Graph
Explanation: A bar graph is ideal for comparing values across different categories such as classes.
Q17. Which graph is more suitable for displaying the number of medals won by different countries?
A. Histogram
B. Line Plot
C. Bar Graph
D. Area Chart
Show Answer
Answer: C. Bar Graph
Explanation: Countries represent categories, making a bar graph the most appropriate choice.
Q18. A horizontal bar graph is especially useful when:
A. Category names are long.
B. Showing trends over time.
C. Displaying frequency distributions.
D. Plotting continuous data.
Show Answer
Answer: A.
Explanation: Horizontal bar graphs provide more space for long category labels, making them easier to read.
Q19. Which graph should be used to compare the number of books available in different sections of a library?
A. Line Plot
B. Histogram
C. Bar Graph
D. Pie Chart
Show Answer
Answer: C. Bar Graph
Explanation: Library sections are categories, making a bar graph the appropriate choice.
Q20. Which statement correctly differentiates a vertical bar graph from a horizontal bar graph?
A. Both represent the same data but in different orientations.
B. A vertical bar graph uses bar(), while a horizontal bar graph uses barh().
C. Both A and B.
D. Neither A nor B.
Show Answer
Answer: C.
Explanation: Both graphs display the same information; the only difference is the orientation of the bars and the function used.
Q21. A company wants to compare the quarterly profits of four branches. Which Matplotlib function should be used?
A. plt.plot()
B. plt.bar()
C. plt.hist()
D. plt.scatter()
Show Answer
Answer: B. plt.bar()
Explanation: Quarterly profits of different branches are categorical data, making a bar graph appropriate.
Q22. Which statement about bar graphs is TRUE?
A. They compare discrete categories.
B. The bars are separated by spaces.
C. They can be drawn vertically or horizontally.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Bar graphs are designed for categorical data, have separated bars, and support both vertical and horizontal orientations.
Q23. Which graph would be the best choice to compare the annual budget allocated to different departments of a school?
A. Histogram
B. Bar Graph
C. Line Plot
D. Scatter Plot
Show Answer
Answer: B. Bar Graph
Explanation: Departments represent categories, making a bar graph suitable for comparison.
Q24. Which of the following statements is TRUE about bar graphs?
A. They compare categorical data.
B. They can be created using plt.bar() or plt.barh().
C. They are commonly used in business, education, and surveys.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Bar graphs are versatile charts used to compare categorical data across many real-world applications.
Q25. Which statement best summarizes Matplotlib Bar Graphs?
A. plt.bar() creates vertical bar graphs.
B. plt.barh() creates horizontal bar graphs.
C. Bar graphs are best suited for comparing values across categories.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Matplotlib provides both vertical and horizontal bar graphs for effectively comparing categorical data.
Answer Key
| Q.No. | Answer | Q.No. | Answer | Q.No. | Answer |
|---|---|---|---|---|---|
| 1 | B | 11 | A | 21 | B |
| 2 | B | 12 | B | 22 | D |
| 3 | B | 13 | B | 23 | B |
| 4 | C | 14 | B | 24 | D |
| 5 | B | 15 | D | 25 | D |
| 6 | D | 16 | C | ||
| 7 | A | 17 | C | ||
| 8 | B | 18 | A | ||
| 9 | A | 19 | C | ||
| 10 | B | 20 | C |
Practice Tips
- Remember the two important Matplotlib functions:
plt.bar()→ Creates a vertical bar graph.plt.barh()→ Creates a horizontal bar graph.
- Use a Bar Graph when you need to compare values across different categories, such as:
- Student marks in different subjects
- Sales of different products
- Population of different cities
- Books in different library sections
- Budget allocation across departments
- Remember the characteristics of a bar graph:
- Represents categorical (discrete) data.
- Bars have equal width.
- Bars are separated by equal gaps.
- Bars can be drawn vertically or horizontally.
- Choose Horizontal Bar Graphs when category names are long, as they improve readability.
- Do not confuse a Bar Graph with a Histogram:
- Bar Graph → Compares categories; bars are separated by gaps.
- Histogram → Represents continuous data; bars touch each other.
- CBSE Tip: Competency-based questions often ask you to identify the most appropriate graph for a given scenario. If the data involves comparing different categories, the correct choice is usually a Bar Graph.