Python Forum
5 Variable- Multiple Boolean Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
5 Variable- Multiple Boolean Code
#1
Currently off by 1.0 with every code attempt.. not sure where:

item = "quesadilla"
meat = "steak"
queso = False
guacamole = False
double_meat = False

# The base price for a quesadilla is 4.00, for nachos is
#   4.50, and for burritoes is 5.00.
# - If meat is steak or pork, add 0.50. Any other meat adds
#   no money to the price.
# - guacamole always adds 1.00 to the price.
# - queso adds 1.00 to the price UNLESS the item is nachos,
#   in which case it adds nothing.
# - double_meat adds 1.50 if the meat is steak or pork, or
#   1.00 otherwise.


if item == "nachos":
    base_price = 4.5
if item == "quesadilla":
    base_price = 4.0
if item == "burrito":
    base_price = 5.0

if double_meat and item == "chicken" or "tofu" or "beef":
    base_price += 1.50
if meat == "steak" and not double_meat:
    base_price += 0.50
if meat == "pork" and not double_meat:
    base_price += 0.50
elif meat == "pork" and double_meat:
    base_price += 1.50
elif meat == "steak" and double_meat:
    base_price += 1.50


if queso and item == "nachos":
    base_price += 0.0
elif queso:
    base_price += 1.0
    
elif guacamole:
    base_price += 1.0    

print(base_price)
Reply


Messages In This Thread
5 Variable- Multiple Boolean Code - by cf25 - Dec-17-2019, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make a variable contain multiple values stevenjwilliams83 10 3,578 Apr-30-2020, 07:22 AM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020