Decisions with if, elif and else
Run different code depending on a condition.
Lesson 4 of 6 8 min
You will learn
- Write if / elif / else blocks
- Indent code correctly
- Build a grade calculator
Choosing a path
Python checks conditions from top to bottom and runs the first block whose condition is True. The code inside a block is indented by 4 spaces.
Python · try it
Output appears here · Ctrl + Enter to run
Checkpoint
1. With marks = 75 in the program above, what grade is printed?