Week 9: Loops
Python code typing course. 18 wpm, 92% accuracy.
Instead of writing the same line over and over, you can use a loop. In Python, a for loop walks through a sequence of values one at a time and runs the same indented lines for each value. This week you write a simple loop that counts with range(). The loop header ends with a colon, and the body below it is indented. Typing this pattern again and again builds rhythm quickly.
What you will learn
On the US English layout, the four symbols are typed like this:
+is the=key held with Shift. Hold Shift with the opposite pinky and press=with the right pinky.=is the=key, pressed with the right pinky.<is the comma key held with Shift. Hold Shift with the opposite pinky and press the comma key with the right middle finger.;is the;key, pressed with the right pinky.
Here is a loop that runs three times:
for i in range(3):
print(i)
The first line ends with a colon, and the second line is indented by four spaces. This week’s list also includes the semicolon, which Python allows when you want to place two statements on the same line.
Technique tips
- Type the colon at the end of the loop header before you type the indented body.
- For
+and<, reach with the finger that owns the key, then return to the home row straight away. - The semicolon uses the right pinky with no Shift. Keep the wrist still while you press it.
- Check that the body is indented the same amount each time. Enter in the practice area repeats the indent for you.
- Keep your eyes on the number inside
range(). A wrong number changes how many times the loop runs.
Lessons
- Lesson 1 (10 to 15 minutes): Learn. Watch the keyboard demo for this week’s four symbols. Then type
for i in range(3):slowly. - Lesson 2 (10 to 15 minutes): Practice. Repeat the
print(i)line under the loop, with its indentation. Check the colon at the end of each header. - Lesson 3 (10 to 15 minutes): Review. Take the 2-minute test built from this week’s loops. Note the symbol you typed least accurately and practice it again next session.
This week’s goal
The goal is 18 wpm with 92% accuracy. The first star comes when you finish the lessons. The second star comes at 92% accuracy, and the third when you also reach 18 wpm. A small mistake inside a loop repeats on every pass, so accuracy comes before speed.
Symbols this week
The colored keys are the ones you learn this week. The color shows which finger presses the key.
This week’s lessons
Do the lessons in order. Each one ends with a test, and your best result is saved.