Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question