and Answers with Certified Solutions
How does Karel know its exact location in the world?
✔✔ Based on its starting position in the grid
What is the purpose of using turnLeft() multiple times in a row?
✔✔ To change Karel’s direction to face right or down
How can Karel recognize patterns in the world?
✔✔ By checking conditions like beepersPresent() and frontIsClear()
Why is it important to test Karel’s program with different worlds?
✔✔ To make sure the code works in all situations
How can you make Karel take a step only if there is no obstacle ahead?
✔✔ Use an if statement with frontIsClear()
1
,What should Karel do if a beeper is blocking its path?
✔✔ Pick it up before moving forward
How does Karel keep track of the number of beepers it has?
✔✔ It doesn’t; Karel only knows if it has at least one or none
What is the effect of defining a function but never calling it?
✔✔ Karel will never execute the function
How can Karel be programmed to navigate around an obstacle?
✔✔ By checking for walls and turning accordingly
What is the best way to make Karel repeat an action until it reaches a goal?
✔✔ Use a while loop
How can Karel detect the edge of the world?
✔✔ By using frontIsClear() and checking if it becomes false
2
, What does Karel do if given a command that makes no sense?
✔✔ Karel crashes with an error message
How can Karel place a beeper only on alternate tiles?
✔✔ Use a loop and an if condition to skip every other step
What is the best way to make Karel follow a zigzag pattern?
✔✔ By alternating movements and turns in a loop
How can Karel know when to stop inside a loop?
✔✔ By checking conditions like frontIsClear() or beepersPresent()
What happens if Karel moves without checking for a wall?
✔✔ Karel crashes if there is a wall ahead
How can Karel be programmed to move in a square path?
✔✔ By repeating a pattern of moving forward and turning left
3