Week 8: Conditions
C code typing course. 17 wpm, 92% accuracy.
A condition lets a program choose a path based on a question. In C, if asks the question. When the condition is true, the block after it runs. When it is false, the else block runs instead. Conditions use symbols such as ==, < and >. This week you learn to type four symbols on the US English layout, including the colon.
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 Shift. Press Shift with the opposite pinky, and press the , key with your right middle finger.>: the . key with Shift. Press Shift with the opposite pinky, and press the . key with your right ring finger.=: the = key, with your right pinky.
Two short examples: if (score > 10) asks whether the score is above 10, and else covers the case when it is not. A label such as case 1: also ends with a colon.
Technique tips
- Think of
ifandelseas a pair. Show which block belongs to which condition by indenting the lines inside each block. - When you check for equality, type
==rather than a single=. One equals sign stores a value, so it does not compare anything. - Enter gives you the right indentation automatically. Check that
elselines up with itsif, but do not add extra spaces by hand. - Look at the screen to confirm the colon,
<and>landed correctly. Verify the symbols from the text, not from your hands.
Lessons
- Lesson 1, learn (10 to 15 minutes): Watch the four symbols on the keyboard demo. Notice which finger holds Shift, then type each symbol five times.
- Lesson 2, practice (10 to 15 minutes): Type short conditions with
ifandelse, such asif (score > 10). Check that everyifline has its parentheses complete. - Lesson 3, review (10 to 15 minutes): Take the two-minute test with condition lines. Save your result and practice the symbols you got wrong.
This week’s goal
This week’s target is 17 WPM and 92% accuracy. Finishing the week’s lessons earns you 1 star. Reach 92% accuracy for 2 stars, and also reach 17 WPM for 3 stars. A wrong symbol in a condition sends the program down the wrong path, so focus on accuracy first.
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.