Open the first program that you have written. You did save it and keep it as I asked you to, didn't you? If not, rewrite it while I wait for you.
Ok, your program should now be displayed in the program window. Now, remember what I told you was the most important thing to do when writing a computer program? If not, go back to the very beginning and read again.
I'm waiting ...
Got it? Right, the most important thing to do is to make it easy for other people to read your program. This takes a lot of practice and usually requires a fair bit of thinking. However, we can use a trick of writing notes meant for other humans only (and not for the computer) inside the program. We call these notes comments. There are a few ways to write comments in a program. I'm going to teach you the simplest way used in Python. Add the following text as the first line of your program:
# My first programSo that it should now look like the following:
# My first program move() move() turn_off()If you are not colour blind, you will see that the line which begins with the symbol #, appears in green. This symbol indicates that the rest of the line is a comment which is ignored by Reeborg (or Python). Having the text for comments shown in green helps us distinguish comments from instructions. There is no special reason for the colour choice; I just chose to write RUR-PLE so that it would appear like that.
What happens if you put the symbol # at the beginning of a command line? Try it, save the resulting program and run it by clicking on the button to see what Reeborg makes of it.
While the creators of Reeborg designed him so that he obeys instructions in English, they realised that not everyone understands English. So, they gave him the ability to easily learn a second language. For example, if we want to tell someone to "move forward" in French, we would say "avance". We can tell Reeborg that "avance" is a synonym of "move" simply by writing
avance = move.
The order here is important; the known command has to be on the right, and the new one has to be on the left. Note that we don't have any parentheses "()" appearing since the parentheses would tell Reeborg that we want him to obey an instruction; here, we are simply teaching him a new word. When we want Reeborg to follow the new instruction, we will use avance().
Write a program with the following instructions:
avance = move avance() turn_off()and save it under "avance.rur". Now, try your new program.
If you want, you can also teach Reeborg a synonym for turn_off. Or, you may give synonyms in a language other than French if you prefer, even creating your own language. Then, watch Reeborg as he obeys instructions written in your language.