Conditional Statements

First Function:drink(money)

def drink(money): 
    if money >= 2: 
        return "You've got yourself a drink!" 
    else: 
        return "No drink for you!" 

print(drink(4))    # Enough money → drink
print(drink(1))    # Not enough → no drink

Explanation:

  • If money is 2 or more, it returns a success message.

  • Otherwise, it returns a rejection message.

Output:


Second Function:alcohol(age, money)

Explanation:

  • Checks both age and money using if, elif, and else.

  • Uses and to combine conditions.

Output:

Last updated