Week 7: Variables and naming

C# code typing course. 16 wpm, 92% accuracy.

A variable is a named box that holds a value. You create it, give it a name and set its first value with =. A good name tells the next reader what the variable holds: score says a lot, while x leaves the reader guessing. This week you practice two symbols. The underscore _ joins words in a name, and = assigns a value.

What you will learn

A variable declaration puts the type, the name and the first value on one line. An underscore can be part of a name:

  • int total_score = 0; creates a whole number called total_score and starts it at zero.
  • string _name = "Ayse"; declares a text value whose name starts with an underscore. Here the underscore is simply part of the name.

In C#, local variable names are usually written in camelCase, which means lowercase at the start and each new word capitalized.

This week’s symbols on the US English layout:

  • _: press - with Shift. Hold Shift with the opposite pinky (the left pinky) and press - with the right pinky.
  • =: press the = key with the right pinky.

Technique tips

  • Press Shift before the underscore and keep it held until the key is down. Release the key first, then Shift. Without Shift you get a plain minus sign.
  • When you type =, picture the name on the left and the value on the right. That order helps you avoid putting the symbol in the wrong place.
  • Type each name as one smooth unit rather than letter by letter. Words like total and score should flow as two beats.

Lessons

  1. Learn (10 to 15 minutes): Watch the demo for _ and =, notice that Shift is needed for the underscore, and type each symbol several times.
  2. Practice (10 to 15 minutes): Type this week’s declaration lines. Keep the order of name, type and value the same on every line.
  3. Review (10 to 15 minutes): Take the two-minute test. Note which symbol gave you trouble and focus on it in the next lesson.

This week’s goal

The goal this week is 16 WPM with 92 percent accuracy. Stars work like this: finish the lesson for 1 star, reach 92 percent accuracy for 2 stars, and reach 16 WPM as well for 3 stars. A missing underscore changes the name, and the code will refer to the wrong variable. Speed comes as you repeat familiar 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

    13 minutes

    Start

All weeks