Last active
January 9, 2018 01:12
-
-
Save monipip3/1e2f25d4dbe66e7b019e17c7181e97c9 to your computer and use it in GitHub Desktop.
Peanut Butter and Jelly Sandwich with if and else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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