wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CodeHS Unit 2 Review Programming with Karel

Total questions: 50

Worksheet time: 37mins

Name
Class
Date
1.
Which of these is a valid Karel command?
a)
move;
move;
b)
MOVE
c)
move();
d)
move()
2.

In the following code snippet, how many times is the turnRight function called and how many times is it defined?

a)

Called 1 time, defined 1 time

b)

Called 1 time, defined 3 times

c)

Called 3 times, defined 1 time

d)

Called 3 times, defined 3 times

3.

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

a)

0 times

b)

1 time

c)

2 times

d)

Howevery many you like

4.

How many times should the start function be called in a program?

a)

0 times

b)

1 time

c)

2 times

d)

However many you like

5.

Why do we use functions in programming?

a)

Break down our code into smaller parts

b)

Avoid repeating code

c)

Make our program more readable

d)

All of the above

6.

What is top down design?

a)

Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.

b)

Top down design is a way that you can create designs on a computer to put on a web page

c)

Top down design is a way of designing your programs starting with the individual commands first

d)

Top down design is a way to use loops and classes to decompose the problem

7.

What is the error with the following function definition?

funtionc coverDot() {

move();

putBall();

turnLeft();

}

a)

The D should not be capitalized

b)

The word “function” is misspelled

c)

The curly brackets are missing

d)

There are too many commands

8.

What belongs inside of the start function?

a)

All new function definitions

b)

Nothing

c)

All lines of code in the program

d)

All the commands you wish to execute

9.

The "function body" is the inside of a function. Which of the following is true about the function body?

a)

All code inside should be indented

b)

All code inside should be capitalized

c)

Commands are not allowed inside

d)

You can only have three commands maximum

10.

What line of code will the computer jump to after reading line 4?

a)

Line 17

b)

Line 5

c)

Line 10

d)

Line 1

11.

Which command is written incorrectly?

a)

putBall();

b)

putball();

c)

turnLeft();

d)

takeBall();

12.

The code in the picture will move Karel in a square.

a)

True

b)

False

13.

Which code will put Karel in the position shown in second world?

a)

putBall(); putBall(); move(); move();

b)

move(); putBall(); move(); putBall();

c)

putBall(); move(); putBall(); move();

d)

move(); putBall(); putBall(); move();

14.

Which code below will put Karel in the position shown in picture?

a)

move(); Move(); turnLeft(); move();

b)

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

c)

move(); move(); TurnLeft(); Move();

d)

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

15.

Is this Function written correctly?

a)

True

b)

False

16.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();

17.

How many times should Karel turn left in order to turn right?

a)

1

b)

2

c)

3

d)

4

18.

What is a code comment?

a)

A way to teach Karel a new word

b)

A way to give notes to the reader to explain what your code is doing

c)

A message to your teacher in code

d)

A place to write whatever you want in your code

19.

What commands does SuperKarel know that regular Karel does not?

a)

turnLeft() and jump()

b)

turnRight() and jump()

c)

turnAround() and turnRight()

d)

turnAround() and jump()

20.

How many times does Karel move with this loop?

a)

9

b)

0

c)

10

d)

1

21.

What does this error mean?

a)

missing ( ) { }

b)

missing ;

c)

missing (

d)

there is no function in the program

22.

How many balls does Karel put down?

(a)  

23.

How many balls does Karel put down?

(a)  

24.

What is the best code to replace condition in this code to make Karel move to the wall in front of her?

a)

facingNorth()

b)

frontIsClear()

c)

noWallsPresent()

d)

facingWall()

e)

true

25.

What does this code do?

a)

Puts down a row of balls

b)

Puts down a column of balls

c)

Puts down balls in a line up to the wall

d)

Removes all of the balls along a path to the wall

26.

Why would we use a while loop instead of a for loop?

a)

we don't know how many times we want to run the loop

b)

we know how many times we want to run the loop

c)

It's a structure that is more efficient to code and execute

d)

it's best practicies

27.
Programming languages give computers instructions
a)
True
b)
False
28.
An error in a program that prevents the program from running as expected.
a)
Error report
b)
Bug
c)
Mistake
d)
Algorithm
29.
A list of steps to finish a task. A set of instructions that can be performed with or without a computer. 
a)
Algorithm
b)
Plan
c)
Binary
d)
Logorithm
30.
An instruction for the computer. Many of these put together make up algorithms and computer programs. 
a)
Code
b)
Plan
c)
Program
d)
Command
31.
Statements that only run under certain conditions or situations.
a)
Conditionals
b)
Run Statements
c)
Digital Statements
d)
Command
32.
Finding and fixing errors in programs
a)
Tech support
b)
Decompose
c)
Debugging
d)
Fixing
33.
What command will place a ball down in a spot?
a)
placeBall();
b)
Putball();
c)
putball():
d)
putBall();
34.
A piece of code that you can easily call over and over again. 
a)
Repeat
b)
Functions
c)
Procedures
d)
Fractions
35.
How many times should Karel turn left in order to turn right?
a)
1
b)
2
c)
3
d)
4
36.

What’s wrong with this code?

function start() {

move();

go();

go();

}


function go() {

move();

move();

}


function go() {

move();

move();

}

a)

The go function is called twice

b)

The go function has a syntax error

c)

The go function has been defined twice

d)

go is not a command that Karel understands

37.

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

38.

What is wrong with this for loop?

for (var i = 0, i < 10, i + 1) {

move();

}

I. The for loop uses commas instead of semicolons

II. It should say i++ instead of i + 1

a)

I

b)

II

c)

I and II

d)

The for loop is correct

39.

What is the proper format for a single line comment in Karel?

a)

/* This is a comment

b)

This is a comment

c)

// This is a comment

d)

** This is a comment

40.

Which of the following is not a valid condition to go in an if statement for Karel?

a)

ballsPresent()

b)

frontIsClear()

c)

leftIsBlocked()

d)

turnLeft()

41.

Why does a programmer indent their code?

a)

Helps show the structure of the code.

b)

Easier for other people to understand.

c)

A key part of good programming style!

d)

All of the above

42.

How can we teach Karel new commands?

a)

For loop

b)

While loop

c)

Define a new function

d)

The start function

43.

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

d)

Nested while loop

44.

Breaking a problem down into smaller problems is called ...

(a)  

45.

whatIsThis

(a)  

46.

What does the "var" keyword represent in the following code:

for(var i=0; i<12; i++) {

a)

Variation

b)

Varicose

c)

Variable

d)

Varietal

47.

An error in the sequence of words or rules in a program that prevents the program from running

a)

Interpreting

b)

Syntax

c)

Compiling

d)

Executing

48.

Non-executing program statements that provide documentation are ___________.  

a)

Comments

b)

Commands

c)

Classes

49.

  An if-else statement runs some code if a condition is true, and another block of code if the condition is false. 

a)

False

b)

True

50.

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

c)

Use a while loop to repeat the move command

d)

Fix the indentation of this program