Skip to content
Question of 97

Q.A pie chart is to be drawn (using pyplot) to represent Pollution Level of Cities. Write appropriate statements in Python to provide labels for the pie slices as the names of the Cities and the size of each pie slice representing the corresponding Pollution of the Cities as per the following table: Cities Pollution Mumbai 350 Delhi 475 Chennai 315 Bangalore 390

(OR)
Write the output from the given Python code: import matplotlib.pyplot as plt Months = ['Dec','Jan','Feb','Mar'] Marks = [70, 90, 75, 95] plt.bar(Months, Attendance) plt.show()
CBSECBSE Class XII Board 2020Subjective· 2mImportance★★★★★
0% · 0/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): use plt.pie(Pollution, labels=Cities) to draw a labelled pie chart of city pollution.

Part (b): the code references an undefined name Attendance, so it fails with NameError and draws nothing.

Part (a)

A pie chart shows each category as a slice whose area is proportional to its value. In pyplot, the first argument of plt.pie() is the list of sizes and the labels argument names each slice.

import matplotlib.pyplot as plt

Cities = ['Mumbai', 'Delhi', 'Chennai', 'Bangalore']
Pollution = [350, 475, 315, 390]

plt.pie(Pollution, labels=Cities)
plt.title("Pollution Level of Cities")
plt.show()
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.