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

  1. About the browser
    This first lesson explains the use of the browser included within RUR-PLE.
  2. 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.
  3. First program
    This lesson what we mean by computer program and introduces two instructions for Reeborg: move() and turn_off().
  4. Dealing with eRRoRs
    Learning about the case sensitivity of Python.
  5. 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.
  6. Making a left turn
    We learn about another instruction for Reeborg: turn_left().
  7. Beepers
    We learn about beepers and the last two commands that Reeborg can obey: pick_beeper() and put_beeper().
  8. Darn bugs!
    In this lesson we learn about bugs and how RUR-PLE can help us find and quash them.
  9. Building walls
    We learn how to add or remove walls in Reeborg's world; this lesson concludes with a few programming challenges.
  10. Definitely avoiding repetitions
    In this lesson, we learn our first python keyword: def.
  11. Avoiding repetitions, again!
    Here, we learn how Reeborg can repeat instructions automatically.
  12. If only Reeborg could decide on his own ...
    In this lesson, we learn our second Python keyword: if.
  13. Listen to me ... or else ....
    In this lesson, we learn our third Python keyword: else.
  14. If, else, if, else, ....
    In this lesson, we learn our fourth and fifth Python keywords: elif and pass.
  15. Not true!?
    In this lesson, we learn our sixth Python keyword: not.
  16. For a while
    In this lesson, we learn our seventh Python keyword: while.
  17. Amazing - part 1
    We put together all we've learned so far to solve a series of exercises, with a surprising conclusion.
  18. Amazing - part 2
  19. Amazing - part 3
  20. Amazing - part 4
  21. Amazing - part 5
  22. It's raining!
    Help Reeborg close the window in his house to prevent the rain from coming in.
  23. After the storm
    Help Reeborg clean up his yard after a wind storm.
  24. Sorting
    Help Reeborg sort some piles of beepers into ascending order.
  25. Avoiding repetitions - the important stuff
    In this lesson we learn about the Python keywords from and import, as well as the pseudo-keyword as.
  26. 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.
  27. 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.
  1. Random escapes
  2. 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.
  3. The meaning of synonyms
  4. A different way of looking at variables assignment and re-assignment, which often confuses beginners.
  5. Many returns
  6. A quick preview of the use of the Python keyword return.
  7. A touch of class
  8. A quick preview of the use of the Python keyword class.
  9. A disappearing act
  10. An example illustrating variable scope in Python.
  11. Lists and dicts
  12. A quick look at the way items get added differently in lists and in dict.
  13. A Robotic Fairy Tale
  14. A review exercise presented as a Fairy Tale.

../images/SourceForge.net Logo