Page 441 - AI_Ver_3.0_class_11
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
   436   437   438   439   440   441   442   443   444   445   446