Learning Python: Child's Play with RUR-PLE!
André Roberge, © 2004, 2005
Learning to program computers should be fun, for adults and children alike. RUR-PLE is an environment designed to help you learn computer programming using the language Python. Within an artificial world in which a robot can be programmed to perform various tasks, you will learn what it means to write a computer program, using Python's syntax. You will also be able to apply your programming skills in a more traditional environment using the built-in interpreter. If these words don't mean much to you for now, don't worry.
While learning to program can be fun, it does require some work on your part. I will be your guide, so that you can learn on your own; however, you will not learn if you do not write your own programs. This is important enough that you should take it as a rule to follow.
- Rule # 1
- Learning about computer programming is like learning to play a musical instrument: you have to do it, not simply read about it.
The second thing you need to know is the most important, best-kept secret for writing good computer programs.
- Rule # 2
- Write your computer programs to make them easy for people to read.
That's right, write your computer programs so that other people, just like you, would find them easy to read on their own. Yes, computer languages are designed to allow you to communicate with computers, just as human languages have evolved to allow humans to communicate with each other. But computer languages, which are much simpler than human languages, are often used by programmers to share their work with other programmers. Just as you can improve your English writing skills by reading well-written novels, you can improve your programming skills by reading well-written computer programs. However, you will still need to write your own programs to learn how to do it.
To get you started on writing computer programs, you will make a robot, named Reeborg, perform certain tasks on your computer screen. While doing so, you will learn universal programming concepts as well as the language named Python. Later on, we will move away from having Reeborg perform tasks, and learn to do other things using the computer.
Find out more about RUR-PLE including a summary of instructions as well as acknowledgements to various people.
List of lessons
About the browser
This first lesson explains the use of the browser included within RUR-PLE.
Reeborg explores its world
In this lesson, you will start getting familiar with Reeborg's environment and learn to use arrows on the keyboard to make Reeborg move.
- First program
This lesson what we mean by computer program and introduces two instructions for Reeborg: move() and turn_off().
- Dealing with eRRoRs
Learning about the case sensitivity of Python.
- Any comments? Avez-vous des commentaires?
We learn how to add additional explanations meant only for humans in programs. These are called comments. We also learn about translating the instructions obeyed by Reeborg into other human languages. This is closely related to the concept of variables which will be introduced much later.
- Making a left turn
We learn about another instruction for Reeborg: turn_left().
We learn about beepers and the last two commands that Reeborg can obey: pick_beeper() and put_beeper().
- Darn bugs!
In this lesson we learn about bugs and how RUR-PLE can help us find and quash them.
- Building walls
We learn how to add or remove walls in Reeborg's world; this lesson concludes with a few programming challenges.
- Definitely avoiding repetitions
In this lesson, we learn our first python keyword: def.
- Avoiding repetitions, again!
Here, we learn how Reeborg can repeat instructions automatically.
- If only Reeborg could decide on his own ...
In this lesson, we learn our second Python keyword: if.
- Listen to me ... or else ....
In this lesson, we learn our third Python keyword: else.
- If, else, if, else, ....
In this lesson, we learn our fourth and fifth Python keywords:
elif and pass.
- Not true!?
In this lesson, we learn our sixth Python keyword: not.
- For a while
In this lesson, we learn our seventh Python keyword:
- Amazing - part 1
We put together all we've learned so far to solve a series of exercises, with a surprising conclusion.
- Amazing - part 2
- Amazing - part 3
- Amazing - part 4
- Amazing - part 5
- It's raining!
Help Reeborg close the window in his house to prevent the rain from coming in.
- After the storm
Help Reeborg clean up his yard after a wind storm.
Help Reeborg sort some piles of beepers into ascending order.
- Avoiding repetitions - the important stuff
In this lesson we learn about the Python keywords from and import, as well as the pseudo-keyword as.
- Teaching Reeborg to add.
We teach Reeborg how to add two numbers on his own. After this lesson, we will temporarily leave Reeborg's world to learn more about Python itself.
- Python already knows how to add.
In this lesson, we explore how Python adds, subtracts, multiplies, divides, ..., numbers.
The shape of things to come
Here are some sample programs illustrating what topics could be covered next. They are very sketchy at this point, and not expected to be useful to students on their own. However, there is probably enough material to enable teachers to prepare real lessons. Note that some of the robot syntax could change slightly before release 1.0.
- Random escapes
Two simple programs that rely on random turns and moves to find the exit from a maze. The first one checks for the presence of a wall in front and moves only if there is none present.
Example of Look before you leap.
The second catches exceptions (rather than checking for the presence of a wall).
Example of Better to ask forgiveness than permission.
Makes use of the Python keywords try and except amongst others.
- The meaning of synonyms
A different way of looking at variables assignment and re-assignment, which often confuses beginners.
- Many returns
A quick preview of the use of the Python keyword return.
- A touch of class
A quick preview of the use of the Python keyword class.
- A disappearing act
An example illustrating variable scope in Python.
- Lists and dicts
A quick look at the way items get added differently in lists and in dict.
- A Robotic Fairy Tale
A review exercise presented as a Fairy Tale.