Week 14: Small programs I
Small Basic code typing course. 23 wpm, 94% accuracy.
This week you combine the pieces you have learned so far into your first small programs. A program usually does three things: it gets information from the user, works with that information, and writes the result to the screen. In Small Basic, these steps are handled with the TextWindow library. This week’s goal is to use the keys from earlier weeks fluently. There are no new symbols, but you will keep your speed and accuracy steady while you write complete programs.
What you will learn
This week has no new symbols. You will use the quotes, parentheses, periods and equals signs from earlier weeks. If you need the right key for one of them, return to the matching week and review it. Here is a short example program:
TextWindow.Write("What is your name? ")
name = TextWindow.Read()
TextWindow.WriteLine("Hello " + name)
The first line asks the user a question. The second line stores the answer in the name variable. The third line greets the user by name. TextWindow.Read() reads the text the user types; to read a number, use TextWindow.ReadNumber().
Technique tips
- Write the program one line at a time. Check each line once you finish it before you start the next.
- Close quotes and parentheses in pairs. Think of the opening symbol, the contents and the closing symbol in that order.
- Remember that you are writing code, not the text on the screen. Keep your eyes on the screen as you type.
- Enter fills in the indentation of the next line. Keep block indentation intact as you type.
- For a longer program, split it into parts and run each part on its own to check it.
Lessons
- Lesson 1, 10 to 15 minutes: Choose two symbols from earlier weeks and watch the keyboard demo again. Type each one three times.
- Lesson 2, 10 to 15 minutes: Write the three-line program above and run it. Then try it with your own name.
- Lesson 3, 10 to 15 minutes: Review what you practiced, then take the 2-minute test.
This week’s goal
The targets are 23 wpm and 94% accuracy. Finishing the lessons earns one star. Reaching 94% accuracy earns the second star. The third star also needs 23 wpm. Short programs written correctly are the best base for longer ones.
This week’s lessons
Do the lessons in order. Each one ends with a test, and your best result is saved.