Consider the following Python code using Matplotlib. What will be the color of the plotted line?
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6], 'g--') plt.show()
Look at the format string 'g--' used in the plot function.
The format string 'g--' means green color ('g') and dashed line style ('--').
Given this code snippet, how many bars will appear in the bar chart?
import matplotlib.pyplot as plt categories = ['A', 'B', 'C', 'D'] values = [5, 7, 3, 8] plt.bar(categories, values) plt.show()
Count the number of categories provided.
There are 4 categories: 'A', 'B', 'C', and 'D', so 4 bars will be shown.
Which code snippet will produce a scatter plot with red circle markers?
Check the color and marker shape parameters.
Option C uses 'c' for color set to 'red' and marker 'o' for circles.
What error will this code produce when run?
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5]) plt.show()
Check the lengths of x and y lists.
The x list has 3 elements but y has 2, so Matplotlib raises a ValueError.
Which code snippet correctly creates a line plot with a legend labeled 'Data' and a grid shown?
Look for correct usage of legend and grid functions.
Option A correctly sets the label, calls plt.legend() without arguments, and enables grid with plt.grid(True).
