Module 4 · Manhattan Navigation
Lesson 4-5 · Turning — Knowledge ChecksAnswer key
The robot faces West (3) and makes one clockwise turn. What does (heading + 1) % 4 give?
3 + 1 is 4, and the remainder of 4 divided by 4 is 0. One clockwise turn from West faces North.
A student's printout shows turning clockwise forever after the first move. What's the likely bug?
The loop ends only when current_heading equals desired_heading. If the turn doesn't add 1 to current_heading, nothing changes and the loop never ends. On screen that's a scrolling printout; on the floor it would be a robot spinning in place.