Pie charts are often used to show parts of a whole. Why do pie charts represent proportions correctly?
Think about how the size of each slice relates to the total data.
Each slice's angle in a pie chart is calculated by dividing the category's value by the total sum, then multiplying by 360 degrees. This makes the slice size proportional to its share of the whole.
Given the data [10, 20, 30], what are the angles in degrees of the pie chart slices?
data = [10, 20, 30] total = sum(data) angles = [(x / total) * 360 for x in data] print(angles)
Calculate each value's fraction of the total, then multiply by 360.
The total is 60. Each angle is (value / 60) * 360. So 10 → 60°, 20 → 120°, 30 → 180°.
Given a list of sales numbers [50, 150, 300], calculate the proportion of each category as decimals rounded to two places.
sales = [50, 150, 300] total_sales = sum(sales) proportions = [round(x / total_sales, 2) for x in sales] print(proportions)
Divide each number by the total sum and round to two decimals.
Total sales = 500. Proportions: 50/500=0.10, 150/500=0.30, 300/500=0.60 (rounded to two decimals). Matches option D. Note: Python prints [0.1, 0.3, 0.6], but the values correspond to C.
Which pie chart correctly shows the proportions of categories [25, 25, 50]?
import matplotlib.pyplot as plt sizes = [25, 25, 50] plt.pie(sizes, labels=['A', 'B', 'C'], autopct='%1.1f%%') plt.show()
Check if the slices add up to 100% and match the data.
The data sums to 100. Two slices are 25% each, and one is 50%. The pie chart must reflect these proportions.
What error does this code produce when trying to plot a pie chart?
import matplotlib.pyplot as plt sizes = [10, 20, 30] angles = [x / sum(sizes) * 360 for x in sizes] plt.pie(angles, labels=['X', 'Y', 'Z']) plt.show()
Think about what plt.pie expects as input values.
Matplotlib's plt.pie expects raw data values, not angles. Passing angles causes the pie slices to be proportional to angles, which distorts the chart.