Instructions

Congratulations, you’ve got a job at Python Pizza. Your first job is to build an automatic pizza order program.

Based on a user’s order, work out their final bill.

Small Pizza: $15

Medium Pizza: $20

Large Pizza: $25

Pepperoni for Small Pizza: +$2

Pepperoni for Medium or Large Pizza: +$3

Extra cheese for any size pizza: + $1

Example Input

size = "L"
add_pepperoni = "Y"
extra_cheese = "N"

Example Output

Your final bill is: $28.

e.g. When you hit run, this is what should happen:

Hint

Think about what you’ve learnt about multiple if statements and see if you can reduce the number of lines of code while having the same functionality.

SOLUTION

print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
extra_cheese = input("Do you want extra cheese? Y or N ")

price=0
if size=="S":
    if add_pepperoni=="N":
        price=15
    else:
        price = 17
elif size=="M":
    if add_pepperoni=="N":
        price=20
    else:
        price = 23
else :
    if add_pepperoni=="N":
        price=25
    else:
        price = 28

if extra_cheese =="Y":
    price = price+1

print(f"Your final bill is : ${price}")

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *