wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CodeHS 5.1

Total questions: 15

Worksheet time: 20mins

Name
Class
Date
1.

Which of these is a valid Karel command?

a)

move()

b)

move;

c)

move();

d)

forward();

2.

If Karel is facing North and the code


runs, which direction is Karel facing now

a)

North

b)

South

c)

East

d)

West

3.

How many times should Karel turn left to turn right?

a)

1

b)

2

c)

3

d)

4

4.

What can be used to have Karel turn right?

a)

A loop

b)

A function

c)

if/else statments

d)

comments

5.

Which function will tell Karel how to spin in a circle two times?

a)
b)
c)
d)
6.

How many times should the start function be defined in a problem?

a)

0

b)

1

c)

2

d)

3

7.

Explain how a while loop is different from a for loop.

4 lines
8.

What is the proper way to write a for loop to repeat something 10 times?

a)

for( i = 0; i < 10; i ++)

b)

for( var i = 0; i < 10; i ++)

c)

for i = 0 to 10 step 1

d)

for (var i = 0; i < 10; i--)

9.

Which code segment answers the questions: If Karel is facing South then turn to face East otherwise face North?

a)
b)
c)
d)
10.

How do you write multi-line comments in JavScript?

a)

//

b)

/*

*/

c)

#

d)

"""

"""

11.

Why do we use functions in Karel programs?

a)

all of the given answers

b)

break down our program into smaller parts

c)

make code more readable

d)

avoid repeating code

12.

How many times is the function CollectCoins called in this code? (Click the picture to see bigger)

a)

1

b)

3

c)

4

d)

5

13.

What does it mean to define a function?

4 lines
14.

Why does a programmer indent their code? Check all that apply.

a)

it helps show the structure of the code

b)

it is a rule of the JavaScript code language

c)

the program in CodeHS does it automatically

d)

easier for people to understand

15.

You should use a (a)   control structure to code Karel to put down 300 tennis balls.