Week 7: Variables and naming

Small Basic code typing course. 16 wpm, 92% accuracy.

A variable is a container that stores a value under a name. When your program needs the same value again and again, you give it a name and write that name each time. A good name tells a reader what the value means at a glance. Small Basic does not distinguish between uppercase and lowercase in names, so name and NAME refer to the same variable. Names may contain letters, digits and underscores, but they cannot start with a digit. This week you practice the underscore and equals symbols while you assign values and rename things clearly.

What you will learn

This week has two symbols. On the US English layout:

  • _: - key + Shift, opposite pinky. Right pinky.
  • =: = key, right pinky.

Example:

studentCount = 25
studentCount = studentCount + 1

The first line stores 25 in the variable. The second line adds 1 and stores the result back in the same variable. The = sign means the value on the right is stored under the name on the left.

Technique tips

  • Both _ and = are typed with the right pinky. Keep that finger in place and move only as needed.
  • For _, keep Shift held while you press the key. If you release Shift too early, you get a hyphen instead.
  • Type spaces around = as a habit, for example name = "Ali". This makes the sign easier to spot on the screen.
  • Capitalize each new word in a name, for example studentCount. Names become easier to read this way.
  • Enter fills in the indentation of the next line. Write variable lines one below another to keep the code tidy.

Lessons

  1. Lesson 1, 10 to 15 minutes: Learn the _ and = symbols. Watch the keyboard demo and type each symbol five times.
  2. Lesson 2, 10 to 15 minutes: Create a variable, change its value and print the new value.
  3. Lesson 3, 10 to 15 minutes: Review what you practiced, then take the 2-minute test.

This week’s goal

The targets are 16 wpm and 92% accuracy. Finishing the lessons earns one star. Reaching 92% accuracy earns the second star. The third star also needs 16 wpm. A single wrong letter in a variable name means the program cannot find it, so take your time with names.

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

    14 minutes

    Start

All weeks