Week 7: Variables and naming

Python code typing course. 16 wpm, 92% accuracy.

A variable stores a value under a name. In Python, a line such as total_score = 0 gives a name a value. Three parts sit side by side in that line: the variable name, the equals sign and the value. This week you practice writing this pattern and separating words in names with underscores. The underscore and the equals sign sit on different keys, so build a steady rhythm for both.

What you will learn

On the US English layout, the two symbols are typed like this:

  • _ is the - key held with Shift. Hold Shift with the opposite pinky and press the - key with the right pinky.
  • = is the = key, pressed with the right pinky.

Here are two lines that use these symbols:

total_score = 0
name = "Ali"

In the first line, the name is total_score and the value is 0. The underscore separates the two words. In the second line the value is text, so it sits inside quotation marks.

Technique tips

  • For the underscore, press Shift with the opposite pinky first, then tap the - key with the right pinky.
  • Say the variable name once in your head before you type it. Knowing the name in advance reduces spelling errors.
  • The name always goes on the left of the equals sign and the value on the right. Keep that order in mind.
  • Use the same spelling every time a name appears. Writing total_score in one line and totalscore in the next causes an error.
  • Keep your right pinky steady for both the - and = keys, and let the rest of your hand stay near the home row.

Lessons

  1. Lesson 1 (10 to 15 minutes): Learn. Watch the keyboard demo for the underscore and the equals sign. Then type total_score = 0 slowly.
  2. Lesson 2 (10 to 15 minutes): Practice. Repeat name = "Ali" and total_score = 0. Check that each name and value is spelled the same way every time.
  3. Lesson 3 (10 to 15 minutes): Review. Take the 2-minute test built from this week’s variable lines. Note the names you typed wrong and practice them again next time.

This week’s goal

The goal is 16 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 16 wpm. A misspelled variable name causes an error on every line that uses it, so get the spelling right before you aim for 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