and Answers with Certified Solutions
How do you make Karel navigate through a maze?
✔✔You can use a combination of `move()`, `turnLeft()`, and condition checks like
`frontIsClear()` or `leftIsClear()` to navigate through the maze.
What should you do if Karel encounters a beeper and you want it to pick it up?
✔✔Use the `pickBeeper()` command to have Karel pick up the beeper from its current location.
How do you make Karel move a specific number of steps?
✔✔You can create a loop that repeats the `move()` command the desired number of times.
What command do you use to have Karel place a beeper on its current square?
✔✔The `putBeeper()` command places a beeper on the current square where Karel is located.
How can Karel turn around and continue moving in the opposite direction?
✔✔You can use two `turnLeft()` commands in a row to turn Karel around.
1
,What is the best way to check if there’s a wall in front of Karel?
✔✔Use the `frontIsBlocked()` condition to check if there is a wall in front of Karel.
How do you make Karel turn right?
✔✔You can make Karel turn right by using three `turnLeft()` commands in succession.
What can Karel do when it reaches the edge of the grid?
✔✔When Karel reaches the edge of the grid, it will stop, and you can use the `frontIsBlocked()`
condition to prevent further movement.
How do you make Karel pick up all the beepers in its path?
✔✔You can use a loop with `pickBeeper()` inside to have Karel pick up all beepers along its
path:
```
while (beeperPresent()) {
pickBeeper();
}
2
, ```
What is the easiest way to make Karel complete a task only if there’s a beeper present?
✔✔You can use an `if` statement like this:
```
if (beeperPresent()) {
pickBeeper();
}
```
How do you check if Karel is facing a particular direction?
✔✔You can use the `facingNorth()`, `facingEast()`, `facingSouth()`, or `facingWest()` functions
to check Karel’s current facing direction.
What do you do if you want Karel to move forward until it hits a wall?
✔✔Use a loop that continues moving Karel until the front is blocked, like this:
```
while (frontIsClear()) {
3