Week 8: Conditions
C# code typing course. 17 wpm, 92% accuracy.
A program does not always follow one path. If a number is below zero, it can show one message, and otherwise it can show another. You write that choice with if and else. In a switch, which checks a value against several options, each option starts with a colon. This week you practice the colon, along with the comparison symbols <, > and = that most conditions need.
What you will learn
A condition starts with a comparison and then opens a block. Seeing the symbols together helps you read code faster:
if (number < 0)checks whether the number is below zero. The<symbol means less than.case 1:marks the start of the first option in aswitch. The colon comes right after the value.
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 , with Shift. Hold Shift with the opposite pinky (the left pinky) and press , with the right middle finger.>: press . with Shift. Hold Shift with the opposite pinky (the left pinky) and press . with the right ring finger.=: press the = key with the right pinky.
Technique tips
- Press Shift before the colon and keep it held until the key is down. The colon sits on the same key as the semicolon, so the Shift makes the difference.
- Before typing a comparison, know both sides. The symbol is easier to place when you know what it compares.
- Enter fills in the next line’s indentation when a condition opens a block. Continue from there rather than retyping the indent.
Lessons
- Learn (10 to 15 minutes): Watch the demo for the four symbols, notice which keys need Shift, and type each one several times.
- Practice (10 to 15 minutes): Type this week’s condition and case lines. Think about the two values on either side of each comparison.
- Review (10 to 15 minutes): Take the two-minute test. Note which symbol caused mistakes and focus on it in the next lesson.
This week’s goal
The goal this week is 17 WPM with 92 percent accuracy. Stars work like this: finish the lesson for 1 star, reach 92 percent accuracy for 2 stars, and reach 17 WPM as well for 3 stars. A missing colon stops a case from working, so accuracy comes 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.