Building an Automatic Pizza Order Program at Python Pizza

How can you build an automatic pizza order program at Python Pizza?

Based on a user's order, how can you work out their final bill?

Building an Automatic Pizza Order Program

To build an automatic pizza order program, you need to calculate the final bill based on the user's order. Here's how you can do it:

1. Start by declaring the prices for the different sizes of pizzas:

  • Small Pizza: $15
  • Medium Pizza: $20
  • Large Pizza: $25

2. Ask the user to input their pizza size preference. You can use a variable, let's say `size`, to store their choice.

3. Next, ask the user if they want to add pepperoni to their pizza. You can use a variable, let's say `add_pepperoni`, to store their choice.

4. If the user has selected a small pizza and wants to add pepperoni, add $2 to the final bill. If the user has selected a medium or large pizza and wants to add pepperoni, add $3 to the final bill.

5. Ask the user if they want to add extra cheese to their pizza. You can use a variable, let's say `add_extra_cheese`, to store their choice.

6. If the user wants to add extra cheese, add $1 to the final bill.

7. Finally, calculate the final bill by adding the base price of the pizza to any additional charges for pepperoni and extra cheese.

8. Display the final bill to the user.

Here's an example implementation in Python:

```python # Step 1 small_pizza_price = 15 medium_pizza_price = 20 large_pizza_price = 25 # Step 2 size = input("Enter the size of pizza (small, medium, or large): ") # Step 3 add_pepperoni = input("Do you want to add pepperoni? (yes or no): ") # Step 4 if size == "small" and add_pepperoni == "yes": final_bill = small_pizza_price + 2 elif (size == "medium" or size == "large") and add_pepperoni == "yes": final_bill = medium_pizza_price + 3 else: # If no pepperoni is added if size == "small": final_bill = small_pizza_price elif size == "medium": final_bill = medium_pizza_price else: final_bill = large_pizza_price # Step 5 add_extra_cheese = input("Do you want to add extra cheese? (yes or no): ") # Step 6 if add_extra_cheese == "yes": final_bill += 1 # Step 7 print("Your final bill is: $" + str(final_bill)) ```

← Careers with high demand in metropolitan areas A high efficiency motor replacement reduction in heat gain calculation →