Page 441 - Ai_V3.0_c11_flipbook
P. 441
Output:
21. Visualize the distribution of different types of transportation used by commuters in a city using a pie chart:
• Car: 40%
• Public Transit: 30%
• Walking: 20%
• Bicycle: 10%
import matplotlib.pyplot as plt
# Data
transport_modes = ['Car', 'Public Transit', 'Walking', 'Bicycle']
percentages = [40, 30, 20, 10]
# Create the pie chart
plt.figure(figsize=(8, 8))
plt.pie(percentages, labels=transport_modes, autopct='%1.1f%%', colors=['red',
'pink ', 'green', 'orange'])
# Add title
plt.title('Distribution of Transportation Modes Used by Commuters')
# Show the plot
plt.show()
Output:
Practical Questions 439

