wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Unit 3 Karel Programming Review 2

Total questions: 15

Worksheet time: 12mins

Name
Class
Date
1.

Which of the following is used to create a loop that executes as long as a condition is true?

a)

for

b)

do-while

c)

while

d)

loop

2.

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

3.

Control structure that lets us do either one section of code or another depending on a test.

a)

If Statement

b)

If/Else Statement

c)

For loop

d)

While Loop

4.

What type of error occurs when the program runs but produces incorrect results?

a)

Syntax error

b)

Runtime error

c)

Logic error

5.

What is the purpose of using an 'if' statement?

a)

To define a new function.

b)

To import external libraries.

c)

To make decisions based on conditions.

d)

To repeat a block of code.

6.

What is a run-time error?

a)

A mistake that occurs during the execution of a program

b)

A mistake in the syntax of the code

c)

A mistake in the logic of the code

d)

A mistake that occurs during code compilation

7.
Finding and fixing errors in programs
a)
Tech support
b)
Decompose
c)
Debugging
d)
Fixing
8.

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()

9.

How many total times will Karel move in this program?

a)

2

b)

3

c)

4

d)

5

10.

What condition should be used in this while loop to get Karel to move until there is a wall in the way?

a)

noBallsPresent();

b)

ballsPresent();

c)

frontIsClear();

d)

turnLeft();

11.

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

12.

You need to write a program that has Karel move if the front is clear, but if it isn’t clear, Karel will do nothing.

Which control structure do you need to use?

a)

For Loop

b)

While Loop

c)

If Statement

d)

If/Else Statement

e)

None of these

13.

What do we use control structures for in JavaScript?

a)

Control the flow of the program; how the commands execute.

b)

Start our JavaScript program

c)

Store information for later

d)

Teach Karel new commands

14.

Which of the following are control structures:

  1. "if" function
  2. "if/else" function
  3. "while" function
  4. "for" function
a)
  1. 1 and 2

b)
  1. 1 and 2

c)
  1. 3 and 4

d)

1, 2, 3, and 4

15.

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