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 if and else as 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 else lines up with its if, 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

  1. 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.
  2. Lesson 2, practice (10 to 15 minutes): Type short conditions with if and else, such as if (score > 10). Check that every if line has its parentheses complete.
  3. 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.

` ~ 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