Week 13: Data structures
Small Basic code typing course. 22 wpm, 94% accuracy.
When you want to keep related facts about one thing, such as a student’s name, age and grade, you use a data structure. In Small Basic, you can reach an array item with a text key as well as a number. That gives you readable code such as student["name"]. This week’s goal is to type curly braces, the colon and the period correctly, so you can build this structure without mistakes.
What you will learn
This week has four symbols. On the US English layout:
{: [ key + Shift, opposite pinky. Right pinky.}: ] key + Shift, opposite pinky. Right pinky.:: ; key + Shift, opposite pinky. Right pinky..: . key, right ring finger.
Example:
student["name"] = "Ali"
student["age"] = 12
Both lines store a value in the same array called student. The text inside the square brackets names the information being stored. The colon is part of this week’s typing drills and does not appear in these examples. The braces are typing drills too; Small Basic code does not use them.
Technique tips
- Press Shift with the opposite pinky for
{,}and:. Keep the right hand steady while Shift is held. - Before you write a data structure, separate the key from the value in your mind. Type
student[, then the key, then], then the value. - The period is easy to miss inside text. Check it after you type it.
- Enter fills in the indentation of the next line. Split long data lines across several lines and keep them aligned.
- Type the quotes around each key along with the key itself, so you never forget them.
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: Create a student record. Write the name and age using keys, then print them.
- Lesson 3, 10 to 15 minutes: Review what you practiced, then take the 2-minute test.
This week’s goal
The targets are 22 wpm and 94% accuracy. Finishing the lessons earns one star. Reaching 94% accuracy earns the second star. The third star also needs 22 wpm. Check the quotes around each key as you type, since a missing one changes the key the program looks for.
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.