To start this assignment, download this zip file.
The following guide pages cover material needed for this assignment:
Lab 2b β Conditions
Preparation
Reminder, you should work in teams of 2 or 3 when solving the lab problems. Learning to code together is an important part of this class.
1 minute
Download the zip file for this lab, located above. This zip file has worlds that
you will use for Bit. Extract the files and put them in your cs110
directory
in a folder called lab2b
.
Paint the box
10 minutes
Bitβs job is to paint a green box. There are two worlds. The first world starts like this:
After Bit paints a green box, it looks like this:
The second world looks like this:
After Bit paints a green box, it looks like this:
You have starter code in paint-the-box.py
.
Notes:
- Your code needs to be general enough to solve both worlds.
- Notice that Bit ends where it starts, facing the same direction.
- Think about the stopping condition β when does Bit stop painting?
- This problem does not use
and
oror
.
Discuss with the TA:
- What was your stopping condition?
- What other conditions did you need?
Red Roses
15 minutes
In this problem, Bit needs to turn all of the roses red. Here is one of the worlds:
At the end, Bit should have turned all of the blue and green squares into red ones:
You have starter code in red-roses.py
.
Notes:
- What is the stopping condition?
- What other conditions do you need?
Discuss with the TA:
- Compare your solution on this problem to the solution on the previous problem.
Clear green
15 minutes
In this problem, Bit needs to clear only the green squares that are next to the black squares. One of the worlds looks like this:
At the end, Bit should have cleared all of the green squares that are next to a black square:
Notes:
- What is the stopping condition?
- What conditions can Bit use to decide whether to erase a square?
Remember, use bit.paint('white')
to erase a square.
Discuss with the TA:
- Did you use two
if
s or oneif
and oneelif
? - Is there any difference?
Wrapup
5 minutes
Discuss any questions about conditions in while loops and if statements.
Grading
To finish this lab and receive a grade, take the canvas quiz.
We are providing a solution so you can check your work. Please look at this after you complete the assignment. π