In this lesson
- It starts with a question. A bus program has three lines. Line 1: fare = 2. Line 2: if age < 12: and, indented under it, line 3: fare = 1. Mere is 15. What is her fare?
- The idea you will find. if runs its block only when the test is true; else runs when it is false. — Every sack printed exactly one word, never both and never neither. Python works out the test, gets True or False, and takes one path. The edge is where mistakes hide: > means “more than”, so 10 did not count, while >= means “this much or more” and would have let it in.
- How you learn it. By doing: sorting, a slider, putting things in order.
- Length. 6 short steps. Progress saves on this phone.
Part of Reading Python
Reading and predicting Python a line at a time, before writing any of your own.