wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CodeHS Intro to Programming - Karel Review

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following commands is a valid Karel command?

a)

turnLeft

b)

turnLeft;

c)

turnLeft();

d)

turnLeft()

2.

What makes this command invalid (incorrect)?

Move();

a)

This command is correct.

b)

It has a capital M.

c)

It has ()

d)

It should be a colon : not a semi colon ;

3.

Which of the following is the correct way to define a turnRight function in Karel?

a)

function turnRight() { turnLeft(); turnLeft(); turnLeft();

}

b)

function turnRight() { turnRight(); turnRight(); turnRight();

}

c)

function turnRight { turnLeft(); turnLeft(); turnLeft();

}

d)

turnRight function() { turnLeft(); turnLeft(); turnLeft();

}

4.

Why do we use functions in Karel programs?

a)

Break down our program into smaller parts

b)

Avoid repeating code

c)

Make our program more readable

d)

All of these!

5.

How many total times will Karel move in this program?

function start() { move(); for (var i = 0; i < 5; i++) { move(); putBall(); } }

a)

1

b)

5

c)

6

d)

7

6.

What is wrong with this for loop?

for (var i = 0; i < 10; i + 1) { move(); }

a)

The for loop uses commas instead of semicolons

b)

It should say i++ instead of i + 1

c)

Nothing is wrong with this loop

d)

The "var" should not be there.

7.

How can we teach Karel new commands?

a)

For loop

b)

While loop

c)

Define a new function

d)

The start function

8.

Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?

a)

If statement

b)

While loop

c)

For loop

9.

How can we improve the following program?

function start() { move(); move(); move(); move(); move(); move(); move(); move(); move(); }

a)

Break down this program into more functions

b)

Use a for loop to repeat the move command

10.

What is the purpose of using a for loop in code?

a)

To do something if a condition is true

b)

To repeat something a fixed number of times

c)

To make programs run faster