Skip to main contentSkip to solution

Arrange the following in the proper sequence (assume that matplotlib.pyplot is imported as plt):

(A) plt.plot(date, list)

(B) list= [8.5, 0.5, 6.8]

(C) date = ["15/12", "16/12", "17/12"]

(D) plt.show()

Solution

✅ Correct Option: 1

Both lists must exist before they are plotted, and plt.show() must come last because it displays whatever has already been plotted.

(B) list= [8.5, 0.5, 6.8] creates the y-values.

(C) date = ["15/12", "16/12", "17/12"] creates the x-values.

(A) plt.plot(date, list) draws the graph using both lists.

(D) plt.show() displays the finished plot.


Options 2 and 3: plt.plot(date, list) is called before date is defined (Option 2 also before list), which gives a NameError.

Option 4: plt.show() runs before plt.plot(...), so nothing is plotted when the window appears.

Keyboard Shortcuts

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