Skip to content

Reeborg, the REEBORGANING!

Reeborg, considerably larger than before, flexing.

Overview

You'll learn to handle both sides of a decision with if/else, and to keep a program running as long as a condition holds with a while loop.

Builds on

More Reeborg! MORE REEBORG!. Keep your saved programs from that lab.

Before you start

Each mission below has its own button that loads the right world. Save your work after every world — you'll turn all of them in at the end. The world names (such as Step 4) are Reeborg's labels; the numbered instructions below are this lab's action steps.

You've got it when…

  • Reeborg walks the whole yard and gathers the corner flowers no matter what size the yard is.
  • Reeborg carries every apple to the compost bin without knowing the count ahead of time.
  • You've saved a .py file for both steps.
  • You've saved library.py if your program imports it.

Collaboration & AI

Work: On your own. You can compare notes with a neighbor, but write your own commands.

AI — AIAS Level 1, No AI: Write and debug your own code without AI assistance. What the levels mean.


Step 11 — if and else

  1. Work through this world, then save your program.

    Open Step 11

    We've already seen how to use if in our programs. Now we'll add a new piece: else.

    if and else choose between two branches. This example illustrates the structure; the weather and activity functions are placeholders, not Reeborg commands:

    if it_rains():
        keep_reading()
    else:
        go_outside_and_play()
    

    Your mission: make Reeborg walk around the outside of the yard gathering flowers from each corner. The length and width of the yard changes each time the program is started, but we know that it will take 23 repetitions of a turn-or-move decision to complete this world, including turns. This is not 23 calls to move(). Use both if and else to determine when to turn at a corner or walk straight.

Step 12 — The while Loop

  1. Work through this world, then save your program.

    Open Step 12

    Now we'll see one of the real kinds of loops that is available in all Python programs (remember, repeat is only available for Reeborg!).

    A while loop does something for as long as a condition is true. It looks like this:

    while front_is_clear():
        move()
    

    Your mission: make Reeborg take the apples from the house to the compost bin outside. We don't know ahead of time how many apples are stacked up in the house. Use a while loop to continue picking them up until there are none left to bring outside.

Check Your Work

  1. Reset and run each mission several times to test different yard sizes and apple counts. Save Step 11.py, Step 12.py, and library.py if either program imports it.

Turn It In

  1. Submit these Python source files:
  • Step 11.py
  • Step 12.py
  • library.py, if imported by your program

Include your library

Save the contents of the library tab separately from Python Code. When reopening your work in Reeborg, restore that code to the library tab before running a program that imports it.


How It's Graded

One score, from 0–4, covers your submitted Python source files.

Score Evidence
4 Excellent Both programs and any imported library are submitted. Step 11 uses if/else to collect the corner flowers; Step 12 uses while to move all apples to the compost.
3 Above Average All required programs work and use the required constructs, with minor errors or omissions in code organization.
2 Average Some required work functions, but a mission, required construct, or source file is missing.
1 Below Average Programs are largely incomplete or nonfunctional.
0 Failing No submission or no evidence of the required work.

Credit: Adapted from Dan Schellenberg's Computer Science 20 textbook.