Maze Master
Step-by-Step Strategies
Karel in the Wild
Debugging Detectives
Karel Quiz Whiz
100

T/F: In an if/else statement, it is possible for both the if block and the else block to run.

  • Answer: False

  • Why: It is a choice: either the if block runs (if the condition is true) or the else block runs (if the condition is false), but never both.

100

T/F: A while loop will continue to run as long as its condition remains true.

  • Answer: True

  • Why: This is the definition of a while loop. It checks the condition, runs the code, and repeats, stopping only when the condition becomes false.

100

T/F: Debugging is the process of writing new functions to add features.

  • Answer: False

  • Why: Debugging is the process of finding and fixing errors (bugs) in your code.

100

T/F: Proper code indentation is technically required for a Karel program to run.

  • Answer: False

  • Why: While not required for the computer to run it, it is essential for human readability and is a critical part of good programming style.

100

T/F: A function call (like move();) is a type of control structure.

  • Answer: False

  • Why: Control structures (like if, for, while) change the flow of the program. A function call is just a command.

200

What is the primary purpose of Karel the Dog in programming education? 

A) To teach object-oriented design 

B) To learn the basics of logic and problem-solving 

C) To build web pages 

D) To learn advanced JavaScript syntax

  • Answer: B

  • Why: Karel provides a simple, visual environment to learn fundamental concepts like commands, logic, and decomposition before adding complex syntax.

200

If Karel is at 3rd Street and 5th Avenue facing East, what will its location be after one move() command? A) 3rd Street and 6th Avenue 

B) 4th Street and 5th Avenue 

C) 3rd Street and 4th Avenue 

D) 2nd Street and 5th Avenue

  • Answer: A

  • Why: Facing East means moving to higher avenues. Streets (North/South) remain unchanged.

200

Which command does Karel use to pick up a tennis ball? 

A) pickBall() 

B) getBall() 

C) takeBall() 

D) removeBall()

  • Answer: C

  • Why: The specific command in the CodeHS Karel library is takeBall().

200

How do you correctly define a turnRight() function for the basic Karel? 

A) function turnRight() { turnLeft(); turnLeft(); }

B) function turnRight() { turnLeft(); turnLeft(); turnLeft(); }

C) function turnRight() { move(); turnLeft(); }

D) function turnRight() { SuperKarel.turnRight(); }

  • Answer: B

  • Why: Turning left three times (90 + 90 + 90 = 270 degrees) results in a right turn.

200

What is the primary benefit of using functions in your code? 

A) It makes the code run faster. 

B) It allows you to avoid writing the same code repeatedly and makes code more readable. 

C) It is the only way to use loops. 

D) It makes the code more colorful.

  • Answer: B

  • Why: Functions promote reusable code (D.R.Y. - Don't Repeat Yourself) and help with decomposition.

300

How do you write a single-line comment in Karel (and JavaScript)? 

A) `` 

B) /* This is a comment */ 

C) `// This is a comment` 

D) `# This is a comment`

  • Answer: C

  • Why: // is for single-line comments. /* ... */ is for multi-line comments.

300

"Starting with the main goal and breaking it into high-level steps, then breaking those steps into smaller steps" describes: 

A) Bottom-up design 

B) Top-down design 

C) Loop design

D) Debugging

  • Answer: B

  • Why: This is the definition of top-down design, starting from the "top" goal.

300

The process of breaking a large, complex problem into smaller, more manageable pieces is called: 

A) Decomposition 

B) Debugging 

C) Commenting 

D) Looping

  • Answer: A

  • Why: Decomposition is the core idea of top-down design, breaking a problem "down" into simpler parts.

300

Which function in a Karel program is automatically run first? 

A) start()

B) karel()

C) The first function defined in the file 

D) main()

  • Answer: D

  • Why: The main() function is the designated entry point for the entire program.

300

What is the correct syntax for calling (using) a function named buildHouse? 

A) function buildHouse(); 

B) buildHouse; 

C) buildHouse() 

D) buildHouse();

  • Answer: D

  • Why: You must use the function name followed by parentheses () and a semicolon ;.

400

What is the purpose of a "precondition" comment? 

A) To describe what the function does in general. 

B) To state what must be true before the function is called for it to work. 

C) To state what will be true after the function is finished. 

D) To explain why the function is needed.

  • Answer: B

  • Why: A precondition is a condition that must be met pre- (before) running the function for it to work correctly.

400

Which command is available in SuperKarel but NOT in the basic Karel? 

A) move() 

B) turnAround() 

C) takeBall() 

D) turnLeft()

  • Answer: B

  • Why: SuperKarel adds turnRight() and turnAround() as built-in commands.

400

Which control structure is best for making Karel move forward exactly 5 times? 

A) if statement 

B) while loop 

C) for loop 

D) if/else statement

  • Answer: C

  • Why: A for loop is used to repeat code a fixed (known) number of times.

400

What is the correct syntax for a for loop that runs 10 times? 

A) for (var i = 0; i < 10; i++) { ... } 

B) for (i = 1 to 10) { ... } 

C) loop (10) { ... } 

D) while (i < 10) { ... }

  • Answer: A

  • Why: This is the standard "counter" loop: initialize i to 0, loop as long as i is less than 10, and increment i each time.

400

Which command does Karel use to put down a tennis ball? 

A) dropBall() 

B) putBall() 

C) leaveBall() 

D) placeBall()

  • Answer: B

  • Why: The command is putBall().

500

What does the condition facingNorth() check? 

A) If there is a wall to the North. 

B) If Karel is currently facing the North direction. 

C) If Karel is on the northernmost street. 

D) If there is a ball to the North.

  • Answer: B

  • Why: It checks Karel's current orientation (direction).

500

If you want Karel to takeBall() only if one is present, what code would you write? 

A) while (ballsPresent()) { takeBall(); } 

B) if (ballsPresent()) { takeBall(); } 

C) if (takeBall()) { ballsPresent(); } 

D) for (var i = 0; i < 1; i++) { takeBall(); }

  • Answer: B

  • Why: An if statement checks a condition once and executes the code if it's true. A while loop (A) would get stuck if there were multiple balls.

500

Which of the following is NOT a valid Karel condition? A) frontIsClear() 

B) ballsPresent() 

C) facingEast() 

D) wallIsPresent()

  • Answer: D

  • Why: The valid conditions are frontIsClear() or frontIsBlocked().

500

An if/else statement is used to... 

A) Repeat a block of code multiple times. 

B) Choose between two different actions based on a condition. 

C) Define a new function. 

D) Stop the program if an error occurs.

  • Answer: B

  • Why: It provides two paths: one for true (the if block) and one for false (the else block).

500

If ballsPresent() is false, which part of this code will run?

if (ballsPresent()) {    

    takeBall(); 

} else {

    putBall(); 

}


A) takeBall();

B) putBall();

C) Both will run. 

D) Neither will run.

  • Answer: B

  • Why: Since the condition (ballsPresent()) is false, the code inside the else block is executed.

M
e
n
u