The Mighty if ๐ฆ
Now that Python can answer True or False, you can make it do things only
sometimes. That's what if is for:
temperature = 35
if temperature > 30:
print("It's a scorcher out there! ๐ฅต")
Two things to notice, and they both matter:
- The
ifline ends with a colon: - The next line is indented (pushed in) โ that's how Python knows which
code belongs to the
if
If the comparison is True, the indented code runs. If it's False, Python skips right over it like it was never there.
Your mission
- Make a variable
scoreand store a number in it - Write an
ifthat prints a celebration message whenscoreis over 100 - Set
scorehigh enough that your message actually shows up!
Your code
Press โถ Run to see what your code does!