wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Fundamentals of Computer Science with Karel Unit 2 Exam

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which command makes Karel move forward one space?

a)

move();

b)

turnLeft();

c)

pickBeeper();

d)

putBeeper();

2.

Which command places a ball in Karel’s current square?

a)

putBall();

b)

move();

c)

turnLeft();

d)

pickBall();

3.

If Karel tries to move into a wall, what happens?

a)

Karel stops and does not move.

b)

Karel moves through the wall.

c)

Karel jumps over the wall.

d)

Karel turns around automatically.

4.

Which loop is best when repeating a fixed number of times?

a)

for loop

b)

while loop

c)

do-while loop

d)

foreach loop

5.

Which condition checks that there is no wall in front of Karel?

a)

frontIsClear()

b)

leftIsBlocked()

c)

rightIsClear()

d)

frontIsBlocked()

6.

Which condition checks if Karel is standing on a ball?

a)

ballsPresent()

b)

noBallsPresent()

c)

frontIsClear()

d)

facingNorth()

7.

We use functions in Karel programs to:

a)

organize code and avoid repetition

b)

make the program run slower

c)

increase the number of errors

d)

limit the program's capabilities

8.

The main difference between an if and a while in Karel is:

a)

An if checks a condition once, while a while repeats as long as the condition is true.

b)

An if repeats as long as the condition is true, while a while checks a condition once.

c)

Both if and while repeat as long as the condition is true.

d)

An if and a while are used for the same purpose in Karel.

9.

At the end, where is Karel and where are the balls?

a)

Karel is at the final position and the balls are collected.

b)

Karel is at the starting position and the balls are scattered.

c)

Karel is outside the grid and the balls are missing.

d)

Karel is in the middle and the balls are in a line.

10.

Trace this: function main() { putBall(); move(); putBall(); move(); } Which squares have balls after running the code?

a)

The first and second squares

b)

The first and third squares

c)

The second and third squares

d)

Only the first square

11.

When Karel executes pickBall(); on an empty square, what happens?

a)

An error occurs.

b)

Karel ignores the command.

c)

A ball appears on the square.

d)

Karel moves to the next square.

12.

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?

a)

Karel is 4 spaces ahead from the start, facing north.

b)

Karel is 3 spaces ahead from the start, facing east.

c)

Karel is 4 spaces ahead from the start, facing east.

d)

Karel is 3 spaces ahead from the start, facing north.

13.

This place has how many balls?

a)

5 balls

b)

4 balls

c)

7 balls

d)

6 balls

14.

14. Fill in missing code to make turnRight using only turnLeft: function turnRight() { ______; ______; ______; }

a)

turnLeft(); turnLeft(); turnLeft();

b)

turnLeft(); turnLeft();

c)

turnLeft(); turnLeft(); turnLeft(); turnLeft();

d)

turnLeft();

15.

Abstraction in Karel programs is defined as:

a)

The process of simplifying complex actions by creating new commands.

b)

The act of moving Karel forward by one step.

c)

The method of increasing the speed of Karel's actions.

d)

The way Karel picks up beepers from the world.

16.

Indentation is important in Karel code because:

a)

it shows the structure of the program and makes the code easier to read.

b)

it makes the program run faster.

c)

it changes the color of the code.

d)

it allows Karel to use more commands.

17.

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?

a)

Karel moves 4 times instead of 5 because the loop runs from 0 to 3 instead of 0 to 4.

b)

Karel picks up a beeper when there is none on the corner.

c)

Karel turns left instead of right at a corner.

d)

Karel places two beepers on the same corner.

18.

Select the correct pseudocode for Karel to pick up a ball 2 steps ahead and return to start.

a)

move; move; pickBall; turnAround; move; move; turnAround;

b)

move; pickBall; move; turnAround; move; turnAround;

c)

move; move; pickBall; move; move; turnAround;

d)

move; move; turnAround; pickBall; move; move;

19.

19. Which of the following is the correct implementation of the function turnAround() for Karel?

a)

function turnAround() { turnLeft(); turnLeft(); }

b)

function turnAround() { turnRight(); turnRight(); }

c)

function turnAround() { move(); move(); }

d)

function turnAround() { pickBeeper(); putBeeper(); }

20.

Which of the following programs correctly makes Karel place a ball on every other square for 6 moves?

a)

for (int i = 0; i < 6; i++) { if (i % 2 == 0) { putBall(); } move(); }

b)

for (int i = 0; i < 6; i++) { putBall(); move(); }

c)

for (int i = 0; i < 6; i++) { if (i % 2 == 1) { putBall(); } move(); }

d)

for (int i = 0; i < 3; i++) { putBall(); move(); move(); }

21.
Karel only knows 4 commands.
a)
True
b)
False
22.
5. A grid that karel lives in.
a)
Define A Function
b)
Fencepost Problem
c)
World
d)
Karel
23.
Walls represent the borders of Karel's world. Can Karel go through these walls?
a)
Yes
b)
No
24.

What happens if Karel tries to put a ball on a square that already has a ball?

a)

Karel skips the command.

b)

An error occurs and the program stops.

c)

Karel removes the existing ball.

d)

Karel places another ball on the same square.

25.

An error in a program that prevents the program from running as expected

a)

Event

b)

Bug

c)

Bit

d)

Loop