Final answer:
To determine the number of pizzas and the total cost for a pizza party, multiply the number of people by the average slices each eats, divide by 12, round up using ceil(), and multiply by the cost per pizza.
Step-by-step explanation:
To calculate the number of pizzas needed for a given number of people attending a pizza party, we first calculate the total number of slices required by multiplying the number of attendees by the average number of slices each person eats. In this case, each person eats 2 slices. Since each pizza has 12 slices, we divide the total number of slices needed by 12 and use the ceil() function from the math module to round up, ensuring we order enough pizzas. Once we know the number of pizzas, we calculate the total cost by multiplying the number of pizzas required by the price per pizza, which is $14.95.
For example, if there are 4 attendees, they would need 2 slices each, totaling 8 slices. Thus, we need 1 pizza (8 / 12, rounded up). The cost for one pizza is $14.95, which we output as $14.95. For 7 attendees, with 14 slices in total needed, we would need to round up to 2 pizzas, because 14 slices divided by 12 is more than 1 but less than 2, and the total cost would then be 2 × $14.95.
To calculate the number of pizzas and the total cost, we need to divide the number of people attending the pizza party by the number of slices each person will eat. Given that each person eats 2 slices and each pizza has 12 slices, we can use the formula:
number of pizzas = ceil(number of people / 2 * 12)
To calculate the total cost, we multiply the number of pizzas by the cost per pizza, which is $14.95. The formula for the total cost is:
total cost = number of pizzas * 14.95
For example, if there are 4 people attending the party, we would need ceil(4 / (2 * 12)) = 1 pizza and the total cost would be 1 * 14.95 = $14.95.