Short Circuiting
evaluate_and = True and False #returns False
#The statement below returns False, but does not evaluate the last True value.
evaluate_and2 = True and False and True have_pb = True
have_jelly = True
have_bread = True
have_butter = False
have_mayo = False
#This is a function in Python. You do not have to know what it is or how to write one.
#For the sake of this exercise only, we will be using it to simulate a child asking
#asking for a sandwich.
def child():
return "I want a sandwich"
######
if (have_pb and have_jelly and have_bread):
print("Make a PB and J sandwich")Last updated
Was this helpful?