Arrange the following python statements for plotting the scatter plot:
(A) import matplotlib library
(B) show the plot
(C) define the two values for x-axis and y-axis
(D) use a scatter plot function
Arrange the following python statements for plotting the scatter plot:
(A) import matplotlib library
(B) show the plot
(C) define the two values for x-axis and y-axis
(D) use a scatter plot function
Solution
✅ Correct Option: 2
(A) Import the matplotlib library, e.g. import matplotlib.pyplot as plt
(C) Define the values for the x-axis and y-axis
(D) Call the scatter function, e.g. plt.scatter(x, y)
(B) Show the plot with plt.show()
Option 1: scatter() needs the x and y values, so they must be defined before it is called.
Options 3 and 4: the library must be imported before any of its functions can be used, and show() always comes last.
Related questions:
2026: 29 May Shift 1