For a program to be useful, it needs to have three qualities:
- Correctness — In other words, the program should do what it's supposed to do. Imagine a calculator program that produced output indicating that 2 + 2 = 3. The usefulness of this calculator would certainly be suspect.
- Efficiency — Now imagine that the calculator were fixed so that it always produced correct output, but took a very long time to do it. Entering 2 + 2 = now returns the proper answer 4, but only after spending 12 minutes processing its input. The usefulness of this calculator would certainly be suspect.
- Clarity — Imagine that the calculator has been altered to be both correct and efficient. What other quality could possibly make it unusable? Imagine a calculator in which to add a 2 and 2, some other key sequence than 2 + 2 must be entered. By not knowing the proper key sequence, or more generally how the calculator functions, you would certainly have doubts about the usefulness of this calculator. Note: The calculator linked above is actually very useful, once you've mastered the input mode. Try the examples linked at the top of the page. How does it work?
Repetition
Repetition Until
There is another Scratch piece that lets us repeat things. It is called repeat until.
- Just like repeat, it will do everything inside the C-shaped block a number of times.
- Just like if, it is dependent upon a condition. Before it starts the loop each time, it checks to see if the condition (below, x > 5) is true. If this is condition is true, then it will not repeat again.
Loops and Variables
This option asks you to program an virtual keyboard! The code to the right gives you a start, but you must add additional functionality, perhaps by adding scripts for other keys on the computer keyboard, so that your electric keyboard can change:
- Volume,
- Instrument,
- Tempo, and/or
- Drum loop/patterns.