AND Operator
def can_have_dessert(ate_meat, ate_vegetables):
if ate_meat and ate_vegetables:
return "You can have dessert!"
else:
return "You can't have dessert because you didn't eat your meat and vegetables."
# Test the function
print(can_have_dessert(True, True)) # Outputs: You can have dessert!
print(can_have_dessert(True, False)) # Outputs: You can't have dessert because you didn't eat your meat and vegetables.
def can_have_dessert(ate_meat, ate_vegetables):
if ate_meat and ate_vegetables:
return "You can have dessert!"
else:
return "You can't have dessert because you didn't eat your meat and vegetables."
# Test the function
print(can_have_dessert(True, True)) # Outputs: You can have dessert!
print(can_have_dessert(True, False)) # Outputs: You can't have dessert because you didn't eat your meat and vegetables.
def can_have_dessert(ate_meat, ate_vegetables): if ate_meat and ate_vegetables: return "You can have dessert!" else: return "You can't have dessert because you didn't eat your meat and vegetables." # Test the function print(can_have_dessert(True, True)) # Outputs: You can have dessert! print(can_have_dessert(True, False)) # Outputs: You can't have dessert because you didn't eat your meat and vegetables.
Leave a Reply