Lesson 4: Making decisions
By the end you can: Use if, elif and else so your program can choose what to do.
1Recall
2New idea
Programs often need to make choices: if it's raining, take an umbrella; otherwise, take sunglasses. In Python we use if and else.
- == means "is equal to" (one = is for putting values in variables)
- Other comparisons: != not equal, < less than, > more than, <= and >=
- The line after if ends with a colon :
- The lines that belong to the if are indented (4 spaces)
- elif means "else, if": a second question to check
3Show me
Try 5, 20 and 30.
4Challenge 1
5Challenge 2
6Check
7At home
8Reflect
- Name a decision a game makes using if.
- Why does the order of if and elif matter in Medal maker?
