Week 9: Loops
Small Basic code typing course. 18 wpm, 92% accuracy.
A loop repeats an action several times. Instead of writing the same line ten times, you can run it ten times with one loop. In Small Basic, a counted repeat uses For, and a repeat that continues as long as a condition holds uses While. This week’s goal is to build loops completely and type the symbols inside them correctly. Do not forget to finish each loop with an EndFor or EndWhile line.
What you will learn
This week has four symbols. On the US English layout:
+: = key + Shift, opposite pinky. Right pinky.=: = key, right pinky.<: , key + Shift (Shift with the left pinky). Right middle finger on the comma key.;: ; key, right pinky.
Example:
For i = 1 To 5 Step 2
TextWindow.WriteLine(i)
EndFor
This loop starts i at 1, adds 2 each time and stops after 5. It writes 1, 3 and 5 to the screen. The semicolon ; is practiced as a typing drill this week. It does not appear in the examples here.
Technique tips
- Press Shift with the opposite pinky for
+. Keep your right hand steady while Shift is held down. - Press Shift with your left pinky for
<, and keep your right middle finger on the comma key. - Start a loop with its
FororWhileline, fill in the body, and finish withEndFororEndWhileat the end. - Enter fills in the indentation of the next line. The body of the loop is indented for you automatically.
- Put spaces between numbers and operators. This makes it easier to follow each step of the loop on the screen.
Lessons
- Lesson 1, 10 to 15 minutes: Learn the four symbols. Watch the keyboard demo and type each symbol three times.
- Lesson 2, 10 to 15 minutes: Write a
Forloop. Then try a shortWhileloop usingWhile x < 10. - Lesson 3, 10 to 15 minutes: Review what you practiced, then take the 2-minute test.
This week’s goal
The targets are 18 wpm and 92% accuracy. Finishing the lessons earns one star. Reaching 92% accuracy earns the second star. The third star also needs 18 wpm. Closing every loop is the first rule of working code, so check for it before you speed up.
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.