Skip to content

ULTIMATE Reeborg!

Reeborg, enormous and caped, ready for the final mission.

Overview

You'll learn two final pieces of Python decision-making — elif and not — and use them to solve the Step 17 maze.

Builds on

Reeborg, the REEBORGANING!. Keep your saved programs from that lab.

Before you start

The mission below has a button that loads the world. Save your work — you'll turn it in at the end.

You've got it when…

  • Reeborg reaches the goal and stops across several Step 17 runs with different starts and goals.
  • Your solution uses a while loop with not, and if/elif/else.
  • You've saved your .py file.
  • 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.


if/elif/else

  1. Read the example and trace which statements run.

    We have seen how if and else work together. Let's add one more piece: "else if", written elif, works like this. The weather, activity, and milk functions below are illustrative placeholders, not Reeborg commands:

    if it_rains():
        play_indoors()
    elif it_snows():
        go_skiing()
    else:
        go_swimming() # assuming it is warm!
    

not

  1. Read the example and trace which statements run.

    Sometimes we want to ask if something is not true. The Python not keyword works like this:

    if not is_raining():
        open_windows()
    

    not can also be used in a while loop:

    while not glass_full():
        pour_milk()
    

Your Mission

  1. Write and test your maze solution.

    Open Step 17

    Help Reeborg solve the maze, regardless of where it starts or where the goal is!

    You must use a while loop with a not, and if/elif/else. Here's how:

    • while Reeborg is not at the goal:
      • if the way is clear to the right, turn right and move forward
      • else, if the way is clear to the front, move forward
      • else turn left

    Wall following

    This strategy is called wall following. Test it in the assigned Step 17 world; it is not guaranteed to solve every possible maze. If Reeborg circles an open area without reaching a wall, first move until it reaches a wall, then begin the right-hand rule. Check for the goal during that initial movement too.

Check Your Work

  1. Reset and run Step 17 several times to test different starting positions and goals. Check that Reeborg reaches the goal and stops. Save Step 17.py and library.py if your program imports it.

Turn It In

  1. Submit these Python source files:
  • Step 17.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 The maze program and any imported library are submitted. The solution uses while not and if/elif/else, reaches the goal, and stops.
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.