Consider the following task: fill the bottom row of a bit world with green.
if the condition was True
run these lines
then check the condition again
Repeating the same lines of code is called a loop.
A loop body contains the instructions we want to run multiple times.
The loop condition determines whether the loop body will be run.
The loop body is indented 4 spaces relative to the
Ideally, we would have something that was
True when it was ok for Bit to move and
False when Bit was blocked.
Bit has a method for checking whether the front of Bit is clear (i.e. a move will not go out of bounds).
True when the space in front of Bit is clear and
False when the space in front is blocked.
A condition is something that is either true or false.
We can represent the concept of true or false in python using the values
A thing that is either
False is called a boolean (named after George Boole).
while loops, always consider the boundary conditions.
A boundary condition is the state of your program when a loop starts or finishes.
while loop, be clear about the boundary conditions.
front_clear(), Bit can also check
You can turn a
False and a
True using the
What happens when the condition of a
while loop is always
Now that you have these colors and tools at your command, let's paint something.
Bit gives us
What new verbs would make this job even easier?