Skip to content

Instantly share code, notes, and snippets.

@monipip3
Last active January 9, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monipip3/1e2f25d4dbe66e7b019e17c7181e97c9 to your computer and use it in GitHub Desktop.
Save monipip3/1e2f25d4dbe66e7b019e17c7181e97c9 to your computer and use it in GitHub Desktop.
Peanut Butter and Jelly Sandwich with if and else
bread = 10
peanut_butter = 20
jelly = 30
if bread > 1 and peanut_butter >= 1 and jelly >= 1:
sandwiches = bread/2
print "I can make {0} PBJ sandwiches today.".format(sandwiches)
elif bread % 2 and peanut_butter >=1 and jelly >= 1:
print "I can make an open face sandwich"
elif bread > 1 and peanut_butter >= 1 and jelly == 0:
bpsandwiches = min(bread/2,peanut_butter)
print "I can make {0} peanut butter sandwiches".format(bpsandwiches)
elif bread > 1 and jelly >= 1 and peanut_butter == 0:
bjsandwiches = min(bread/2,jelly)
print "I can make {0} jelly sandwiches".format(bjsandwiches)
else:
if bread < 2:
print "you need more bread"
if jelly < 1:
print "You need more jelly"
if peanut_butter < 1:
print "You need more peanut_butter"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment