Skip to main content
🐍 Python Basics 🐍

Making Choices πŸ”€

Real programs make decisions. Python uses if and else:

If something is true, do this. Else (otherwise), do that.

def weather(rainy):
    if rainy:
        return "umbrella β˜”"
    else:
        return "sunglasses 😎"

Two important things about Python:

  • There are no braces {}. Instead, the indentation (4 spaces) shows what's inside the if.
  • The line ends with a colon :.

If rainy is true, it returns the umbrella. Otherwise, the sunglasses. Read it carefully, then answer below. πŸ‘‡

What does weather(True) hand back?

What does weather(False) hand back?

In Python, what shows what's inside an if?