Week 15: Small programs II

Small Basic code typing course. 24 wpm, 94% accuracy.

This week you take one step further than the programs in the previous week. Putting a condition inside a loop lets your program check many values one by one. In a structure like this, the indentation of each block shows how the code is organized. This week’s goal is to write nested blocks neatly and to add every closing line. As the number of blocks grows, it becomes easier to forget an EndFor or an EndIf, so add each closing line as soon as you open a block.

What you will learn

This week has no new symbols. You will use the loops, conditions, parentheses and quotes from earlier weeks. If you need the key for one of them, return to the matching week and review it. Here is an example loop:

For i = 1 To 3
  TextWindow.WriteLine(i)
EndFor

This loop sets i from 1 to 3 and writes each value to the screen. The line inside the loop is indented, so you can see at a glance which code belongs to the loop.

Technique tips

  • When you open a block, type its closing line right away and then fill in the body. This keeps the block from going unfinished.
  • In nested blocks, keep the indentation of each level separate. Enter fills in the indentation for you, so focus on the content.
  • Keep closing parentheses and quotes in pairs, as you did in earlier weeks. The habit matters more as blocks multiply.
  • Prefer short lines over long ones. Review each line as soon as you finish it.
  • Before you run a program, count its blocks from top to bottom and check that each one has its closing line.

Lessons

  1. Lesson 1, 10 to 15 minutes: Write the three-line loop above and run it. Check the indentation on every line.
  2. Lesson 2, 10 to 15 minutes: Put an If block inside the loop. Predict which values will be printed, then run the program to check.
  3. Lesson 3, 10 to 15 minutes: Review what you practiced, then take the 2-minute test.

This week’s goal

The targets are 24 wpm and 94% accuracy. Finishing the lessons earns one star. Reaching 94% accuracy earns the second star. The third star also needs 24 wpm. Writing every closing line in nested blocks is the main goal this week.

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

    Keywords

    12 minutes

    Start
  2. Lesson 2: Practice

    Practice

    12 minutes

    Start
  3. Lesson 3: Review and test

    Review and test

    13 minutes

    Start

All weeks