Observe the following graph and find the missing statement in the Python code.

2023

Observe the following graph and find the missing statement in the Python code.

image.png
  1. A.

    pl.bar([5, 2, 3, 1])

  2. B.

    pl.scatter([5, 2, 3, 1])

  3. C.

    pl.plot([5, 2, 3, 1])

  4. D.

    pl.line([5, 2, 3, 1])

Attempted by 1113 students.

Show answer & explanation

Correct answer: C

Answer: Use pl.plot([5, 2, 3, 1]). Explanation: The shown graph is a line graph that connects the data points. pl.plot draws a line by default when given a single list of y-values (x values are taken as 0, 1, 2, ...). pl.bar([5, 2, 3, 1]) creates a bar chart (bars), not a connected line.

Explore the full course: Bpsc