Matplotlib Basics & Line Plot MCQs | 25 Practice Questions with Answers | CBSE Class 12 Informatics Practices (IP)
Class 12 · Informatics Practices
Matplotlib Basics & Line Plot MCQs (25 Questions)
Practice these multiple-choice questions to strengthen your understanding of Matplotlib and Line Plots. Click Show Answer to reveal the correct answer and explanation.
Q1. What is the primary purpose of Data Visualization?
A. To write Python programs
B. To present data graphically for better understanding
C. To create databases
D. To store data permanently
Show Answer
Answer: B. To present data graphically for better understanding.
Explanation: Data visualization converts numerical data into graphical form, making patterns and trends easier to understand.
Q2. Which Python library is commonly used for data visualization?
A. Pandas
B. NumPy
C. Matplotlib
D. CSV
Show Answer
Answer: C. Matplotlib
Explanation: Matplotlib is the most widely used Python library for creating graphs and charts.
Q3. Which module of Matplotlib is commonly used for plotting graphs?
A. pyplot
B. graph
C. charts
D. plotter
Show Answer
Answer: A. pyplot
Explanation: The pyplot module provides functions to create various types of plots.
Q4. Which statement correctly imports the pyplot module?
A. import matplotlib.pyplot as plt
B. import pyplot
C. import matplotlib
D. from pyplot import *
Show Answer
Answer: A.
Explanation: The standard import statement is import matplotlib.pyplot as plt.
Q5. Which function is used to create a line plot in Matplotlib?
A. line()
B. plot()
C. draw()
D. graph()
Show Answer
Answer: B. plot()
Explanation: The plot() function creates a line graph.
Q6. Which function displays the graph on the screen?
A. display()
B. plot()
C. show()
D. graph()
Show Answer
Answer: C. show()
Explanation: The show() function displays the graph window.
Q7. Which function saves a graph as an image file?
A. save()
B. savefig()
C. export()
D. write()
Show Answer
Answer: B. savefig()
Explanation: The savefig() function saves the current figure to a file.
Q8. A line plot is mainly used to show:
A. Distribution of data
B. Trends and changes over time
C. Comparison of categories only
D. Frequency of values only
Show Answer
Answer: B.
Explanation: Line plots are ideal for showing trends and continuous changes.
Q9. Which axis generally represents the independent variable?
A. Y-axis
B. X-axis
C. Z-axis
D. None of these
Show Answer
Answer: B. X-axis
Explanation: The X-axis usually represents the independent variable.
Q10. Which axis generally represents the dependent variable?
A. X-axis
B. Z-axis
C. Y-axis
D. None of these
Show Answer
Answer: C. Y-axis
Explanation: The Y-axis usually represents the dependent variable.
Q11. Which of the following statements about a line plot is TRUE?
A. It connects data points with straight lines.
B. It is useful for displaying trends.
C. It can compare changes over time.
D. All of these.
Show Answer
Answer: D.
Explanation: Line plots connect data points and help visualize trends over time.
Q12. Which of the following is the correct alias for the pyplot module?
A. mp
B. py
C. plt
D. ml
Show Answer
Answer: C.
Explanation: plt is the standard alias for matplotlib.pyplot.
Q13. Which type of graph is most suitable for displaying the monthly sales of a company over one year?
A. Pie Chart
B. Line Plot
C. Histogram
D. Table
Show Answer
Answer: B. Line Plot
Explanation: Line plots effectively display trends over time.
Q14. Which statement creates a basic line plot?
A. plt.plot(x, y)
B. plt.line(x, y)
C. plt.graph(x, y)
D. plt.chart(x, y)
Show Answer
Answer: A.
Explanation: The plot() function is used to create a line graph.
Q15. Which statement about Matplotlib is correct?
A. It creates graphs and charts.
B. It is a Python visualization library.
C. It works well with Pandas.
D. All of these.
Show Answer
Answer: D.
Explanation: Matplotlib is a powerful visualization library that integrates seamlessly with Pandas.
Q16. Which component of a graph represents the complete drawing area in Matplotlib?
A. Axis
B. Figure
C. Label
D. Legend
Show Answer
Answer: B. Figure
Explanation: A Figure is the complete drawing area that contains one or more plots (axes).
Q17. Which component represents the area where data is actually plotted?
A. Figure
B. Axis (Axes)
C. Label
D. Title
Show Answer
Answer: B. Axis (Axes)
Explanation: The Axes object is the region inside the Figure where the graph is drawn.
Q18. A teacher wants to compare students' marks in five monthly tests to observe improvement over time. Which graph is most appropriate?
A. Histogram
B. Line Plot
C. Pie Chart
D. Table
Show Answer
Answer: B. Line Plot
Explanation: A line plot clearly shows changes and trends over time.
Q19. A company wants to show the monthly sales trend for one year. Which type of graph should be used?
A. Line Plot
B. Histogram
C. Text File
D. DataFrame
Show Answer
Answer: A. Line Plot
Explanation: Line plots are ideal for showing continuous changes over regular intervals such as months.
Q20. Which function should be called after creating a plot to display it on the screen?
A. plt.display()
B. plt.show()
C. plt.view()
D. plt.print()
Show Answer
Answer: B. plt.show()
Explanation: The show() function displays the generated plot.
Q21. Which function saves the graph as an image file without displaying it?
A. plt.show()
B. plt.save()
C. plt.savefig()
D. plt.export()
Show Answer
Answer: C. plt.savefig()
Explanation: The savefig() function stores the graph as an image file such as PNG or JPG.
Q22. Which statement is TRUE about plt.show() and plt.savefig()?
A. show() displays the graph.
B. savefig() saves the graph to a file.
C. Both are Matplotlib functions.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Both functions are commonly used together while working with Matplotlib graphs.
Q23. Which of the following is an application of a line plot?
A. Showing annual rainfall over several years
B. Displaying stock price trends
C. Representing temperature changes during a week
D. All of these
Show Answer
Answer: D. All of these.
Explanation: Line plots are suitable for representing continuous data and trends over time.
Q24. Which statement correctly describes the purpose of plotting?
A. It helps identify trends and patterns.
B. It makes numerical data easier to understand.
C. It supports comparison of values visually.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Data visualization helps users quickly understand patterns, comparisons, and relationships in data.
Q25. Which statement best summarizes Matplotlib and Line Plots?
A. Matplotlib is a Python library for data visualization.
B. The plot() function creates line graphs.
C. show() displays the graph, while savefig() saves it to a file.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: Matplotlib provides comprehensive tools for creating, displaying, and saving line plots, making it an essential library for data visualization.
Answer Key
| Q.No. | Answer | Q.No. | Answer | Q.No. | Answer |
|---|---|---|---|---|---|
| 1 | B | 11 | D | 21 | C |
| 2 | C | 12 | C | 22 | D |
| 3 | A | 13 | B | 23 | D |
| 4 | A | 14 | A | 24 | D |
| 5 | B | 15 | D | 25 | D |
| 6 | C | 16 | B | ||
| 7 | B | 17 | B | ||
| 8 | B | 18 | B | ||
| 9 | B | 19 | A | ||
| 10 | C | 20 | B |
Practice Tips
- Remember the standard import statement:
import matplotlib.pyplot as plt
- Revise the important Matplotlib functions:
plt.plot()→ Creates a line plot.plt.show()→ Displays the graph.plt.savefig()→ Saves the graph as an image file.
- Understand the graph components:
- Figure → The complete drawing area.
- Axes → The region where the data is plotted.
- X-axis → Usually represents the independent variable.
- Y-axis → Usually represents the dependent variable.
- Know when to use a Line Plot:
- Monthly sales trends
- Temperature changes
- Rainfall records
- Stock market trends
- Student performance over time
- Understand the purpose of data visualization:
- Identify trends
- Compare values
- Detect patterns
- Present data clearly
- CBSE Tip: Competency-based questions often ask you to identify the correct graph for a given scenario and the appropriate Matplotlib function (
plot(),show(), orsavefig()). Focus on practical applications rather than only memorizing function names.