Python Logic

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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.