A picture of five numbers
The table of sales has five rows. You can read it. But a reader wants to know which city is ahead and by how much, and a picture answers that in a second where a table takes ten.
import matplotlib.pyplot as plt — the same shape of line as pandas, with plt as the nickname everybody uses.plt.bar(x, heights) takes two things: what goes along the bottom, and how tall each bar should be. One bar per entry, in the order they appear.Nothing in this problem will stop the programme. Every wrong choice produces a picture that looks like a real chart, which is precisely why charts mislead so easily. Read the axis labels and the bar heights, every time, including on your own work.
plt.title(...) says what the chart is about.plt.xlabel(...) and plt.ylabel(...) say what each axis measures, and in what units. "Sales" is not a unit; "Sales (lakh rupees)" is.The bars themselves carry no units at all. A reader who cannot tell whether 391 means rupees, lakhs or cartons has been given a decoration rather than a chart.
plt.show() puts the figure on screen. Until you call it, matplotlib has been building the chart quietly in memory and nothing has appeared.A programme that draws a perfect chart and never calls
plt.show() runs without error and displays nothing. If you are sure your plotting code is right and no window has opened, this is almost always why.The file you are given
Build the programme
Your plan
The steps still to place
The whole programme is laid out below. Five pieces are missing, and not one of them can stop the programme. Every combination draws something; only one combination draws the chart you were asked for.
Leave nothing on "choose…". A wrong pick does not always cause an error — sometimes it just prints something you did not expect, which is the harder kind of mistake to spot.
Run and read
Here is the whole programme. Press run and the figure appears underneath, exactly as your choices describe it. Check the bar heights against the file above before you believe anything.