Which command makes Karel move forward one space?
move();
What keyword defines a new function?
function
What keyword checks if a condition is true?
if
Where does Karel start in the default world?
Row 1, Column 1, facing East.
What is the purpose of comments in code?
To explain what the code does for human readers.
What command does Karel use to place a tennis ball?
putBall();
Which loop repeats a fixed number of times?
for loop
What condition checks if there are balls on the current tile?
ballsPresent()
What happens if Karel tries to move into a wall?
Karel crashes — program ends in error.
What happens if you call a function that doesn’t exist?
The program gives an error (“undefined function”).
What is wrong with this command: turnleft();
The “l” should be capitalized — correct command is turnLeft();
What does this code do?
for (let i = 0; i < 3; i++) {
move();
}
Move forward 3 times
What is the opposite of frontIsClear()?
frontIsBlocked()
In SuperKarel, what extra commands are available?
turnRight() and turnAround()
Why do we indent code?
To show structure and improve readability.
Write the correct syntax for defining a new function called turnRight.
function turnRight() {
turnLeft();
turnLeft();
turnLeft();
}
What is “top-down design”?
Breaking a big problem into smaller, easier parts.
What happens when the condition in an if is false?
The else part runs (if there is one).
If Karel moves twice, turns left, moves once, and turns right — where is she?
One row up and two columns over (Row 2, Col 3 if starting at 1,1 East).
What’s the best first step when debugging?
Add comments or print/log statements to trace behavior.
Why do programmers use semicolons after commands in Karel?
They mark the end of a statement in JavaScript syntax.
What’s wrong with this loop?
for (let i = 0, i < 10, i + 1) { move(); }
Uses commas instead of semicolons and should use i++.
What does this code do?
Moves forward until Karel is standing on a tennis ball.
What does a precondition describe in comments?
The state of the world before the code runs.
Why use functions like main() and helper functions instead of one long code block?
To organize code, make it reusable, and improve clarity.