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

  1. 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.
  2. 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.
  3. 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.

` ~ 1 ! 2 @ 3 # 4 $ 5 % 6 ^ 7 & 8 * 9 ( 0 ) - _ = + Backspace Tab Q W E R T Y U I O P [ { ] } \ | Caps A S D F G H J K L ; : ' " Enter Shift Z X C V B N M , < . > / ? Shift Ctrl Win Alt Alt Gr Win Menu Ctrl

This week’s lessons

Do the lessons in order. Each one ends with a test, and your best result is saved.

  1. Lesson 1: Learn

    New symbols: + = < ;

    12 minutes

    Start
  2. Lesson 2: Practice

    Practice

    12 minutes

    Start
  3. Lesson 3: Review and test

    Review and test

    12 minutes

    Start

All weeks