NEW
Font size
WorksheetsFundamentals of Computer Science with Karel Unit 2 Exam
Total questions: 25
Worksheet time: 13mins
Which command makes Karel move forward one space?
move();
turnLeft();
pickBeeper();
putBeeper();
Which command places a ball in Karel’s current square?
putBall();
move();
turnLeft();
pickBall();
If Karel tries to move into a wall, what happens?
Karel stops and does not move.
Karel moves through the wall.
Karel jumps over the wall.
Karel turns around automatically.
Which loop is best when repeating a fixed number of times?
for loop
while loop
do-while loop
foreach loop
Which condition checks that there is no wall in front of Karel?
frontIsClear()
leftIsBlocked()
rightIsClear()
frontIsBlocked()
Which condition checks if Karel is standing on a ball?
ballsPresent()
noBallsPresent()
frontIsClear()
facingNorth()
We use functions in Karel programs to:
organize code and avoid repetition
make the program run slower
increase the number of errors
limit the program's capabilities
The main difference between an if and a while in Karel is:
An if checks a condition once, while a while repeats as long as the condition is true.
An if repeats as long as the condition is true, while a while checks a condition once.
Both if and while repeat as long as the condition is true.
An if and a while are used for the same purpose in Karel.
At the end, where is Karel and where are the balls?
Karel is at the final position and the balls are collected.
Karel is at the starting position and the balls are scattered.
Karel is outside the grid and the balls are missing.
Karel is in the middle and the balls are in a line.
Trace this: function main() { putBall(); move(); putBall(); move(); } Which squares have balls after running the code?
The first and second squares
The first and third squares
The second and third squares
Only the first square
When Karel executes pickBall(); on an empty square, what happens?
An error occurs.
Karel ignores the command.
A ball appears on the square.
Karel moves to the next square.
12. After executing the function main() { for (var i = 0; i < 3; i++) { move(); } turnLeft(); move(); }, where is Karel and which way is Karel facing?
Karel is 4 spaces ahead from the start, facing north.
Karel is 3 spaces ahead from the start, facing east.
Karel is 4 spaces ahead from the start, facing east.
Karel is 3 spaces ahead from the start, facing north.
This place has how many balls?
5 balls
4 balls
7 balls
6 balls
14. Fill in missing code to make turnRight using only turnLeft: function turnRight() { ______; ______; ______; }
turnLeft(); turnLeft(); turnLeft();
turnLeft(); turnLeft();
turnLeft(); turnLeft(); turnLeft(); turnLeft();
turnLeft();
Abstraction in Karel programs is defined as:
The process of simplifying complex actions by creating new commands.
The act of moving Karel forward by one step.
The method of increasing the speed of Karel's actions.
The way Karel picks up beepers from the world.
Indentation is important in Karel code because:
it shows the structure of the program and makes the code easier to read.
it makes the program run faster.
it changes the color of the code.
it allows Karel to use more commands.
An off-by-one error occurs when a loop iterates one time too many or one time too few. Which of the following is an example of an off-by-one error in Karel?
Karel moves 4 times instead of 5 because the loop runs from 0 to 3 instead of 0 to 4.
Karel picks up a beeper when there is none on the corner.
Karel turns left instead of right at a corner.
Karel places two beepers on the same corner.
Select the correct pseudocode for Karel to pick up a ball 2 steps ahead and return to start.
move; move; pickBall; turnAround; move; move; turnAround;
move; pickBall; move; turnAround; move; turnAround;
move; move; pickBall; move; move; turnAround;
move; move; turnAround; pickBall; move; move;
19. Which of the following is the correct implementation of the function turnAround() for Karel?
function turnAround() { turnLeft(); turnLeft(); }
function turnAround() { turnRight(); turnRight(); }
function turnAround() { move(); move(); }
function turnAround() { pickBeeper(); putBeeper(); }
Which of the following programs correctly makes Karel place a ball on every other square for 6 moves?
for (int i = 0; i < 6; i++) { if (i % 2 == 0) { putBall(); } move(); }
for (int i = 0; i < 6; i++) { putBall(); move(); }
for (int i = 0; i < 6; i++) { if (i % 2 == 1) { putBall(); } move(); }
for (int i = 0; i < 3; i++) { putBall(); move(); move(); }
What happens if Karel tries to put a ball on a square that already has a ball?
Karel skips the command.
An error occurs and the program stops.
Karel removes the existing ball.
Karel places another ball on the same square.
An error in a program that prevents the program from running as expected
Event
Bug
Bit
Loop
