Description: A simple exercise in printing the names of random numbers, comparing the use of "otherwise if...", a switch statement, or a table-based alternative.
The final "otherwise" here will fire only if none of the earlier conditions applies; we could leave it out and print nothing in the case that N is 4 or 5.
The more compact way to do this is to create a list of values that our number could match; in many programming languages this is called a switch statement. For example:
{**}When play begins:
let Y be a random number between 6 and 10;
if Y is:
-- 6: say "Six is the magic number!";
-- 7: say "The number of the day is seven!";
-- otherwise: say "Today's magic number is boring."
As a final option, we can use a construction we've seen only briefly before now: a table. The use of tables will be explained more fully in their own chapter, but here we see in brief that we can assign a number of values to one column of a table and then use that table to look up output: