2.23 LAB: Pizza party
Given the number of people attending a pizza party, output the number of people, number of pizzas needed, and the total cost for the number of pizzas. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95.
Output each floating-point value with two digits after the decimal point using the following statement:
print(f'Cost for {numPizzas} pizza(s): ${cost:.2f}')
Hint: Use the ceil() function from the math module to round up the number of pizzas so that enough pizzas are ordered.
Ex: If the input is:
20
The output is:
People: 20
Pizza(s): 4
Cost for 4 pizza(s): $59.80
\bold{Here's what I got but none of it is checking out. I think I might need a whole new code but I don't know how to do that just yet:}
import math
# Number of people attending the party
people = int(input(20))
# Number of slices each person eats
slices_per_person = 2
# Number of slices in a pizza
slices_per_pizza = 12
# Cost of a pizza
pizza_cost = 14.95
# Calculate the total number of slices needed
total_slices = 20 * 2
# Calculate the number of pizzas needed
pizzas = math.ceil(2 / 12)
# Calculate the total cost
cost = 4 * 59.80
# Print the results
print('Pizzas: {}'.format(4))
print('Cost: ${:.2f}'.format(59.80))