Week 7: Variables and naming
C code typing course. 16 wpm, 92% accuracy.
A variable is a named box that holds a value. In C, a variable name cannot contain spaces, and it cannot start with a digit. To join words in a name, programmers often use an underscore, as in total_score. You give a variable its value with =. This week you learn to type both symbols on the US English layout.
What you will learn
On the US English layout:
_: the - key with Shift. Press Shift with the opposite pinky, and press the - key with your right pinky.=: the = key, with your right pinky.
Two examples: total_score and player_name are both clear variable names. The underscore takes the place of a space, so the words stay readable.
Technique tips
- When you type the underscore, press Shift with the opposite pinky first, then reach to the - key with your right pinky.
- Use lowercase letters and separate words with underscores. Names starting with a capital letter are also valid, but aim for one style this week.
- Type the value right after the equals sign, as in
total_score = 0. Keeping the name and value on one line makes the assignment easy to check. - Look at the screen. Make sure each underscore sits between two words, not at the end of a name by mistake.
Lessons
- Lesson 1, learn (10 to 15 minutes): Watch the
_and=symbols on the keyboard demo. Type each one five times. - Lesson 2, practice (10 to 15 minutes): Type names such as
total_score,player_nameandbest_score. Check the underscores in each name one by one. - Lesson 3, review (10 to 15 minutes): Take the two-minute test with variable names and assignments. Save your result and practice the names you got wrong.
This week’s goal
This week’s target is 16 WPM and 92% accuracy. Finishing the week’s lessons earns you 1 star. Reach 92% accuracy for 2 stars, and also reach 16 WPM for 3 stars. One wrong underscore makes the program look for a name that does not exist, so type slowly and carefully.
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.