wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SECURITY: Unit 4 Review

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

How can we improve the following program?

a)

Break down the 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 and remove a bracket

2.

In the following code, what happens to Karel if a ball is present?

a)

Karel will put down a ball

b)

Karel will move

c)

Karel will stop

d)

Karel will pick up the ball

3.

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 do something if a condition is false

d)

To make the program run faster

4.

What makes the following command an invalid Karel command?


turnleft();

a)

the semicolon shouldn't be there

b)

the 'l' should be a capital 'L'

c)

it should start with a capital 'T'

d)

the command is correct

5.

What is wrong with this code?

a)

The go function is called twice

b)

The go function has a syntax error

c)

The go function has been defined twice

d)

The go function does not work

6.

How many total times will Karel move in this program?

a)

5

b)

6

c)

7

d)

8

7.

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

8.

A bakery has 10 cookies in its inventory. How can you store this information in a JavaScript variable?

a)

var = cookies + 10;

b)

var cookies = 10;

c)

var cookies == 10;

d)

cookies = 10 Var()

9.

Why do programmers 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.

10.

How can we teach Karel new commands?

a)

For loop

b)

While loop

c)

If statement

d)

Define a function

11.

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

a)

If statements

b)

While loop

c)

New function

d)

For loop

12.

Which of the following items in the array is [2]?

a)

Milk

b)

Eggs

c)

Cookies

d)

Cake

13.

What is an array (or list)?

a)

An unordered collection of unique items

b)

An ordered collection of items

c)

A collection of (key, value) pairs

d)

A collection of items stored at (row, column) locations

14.

In this example, what Country will print on the screen?

a)

Greece

b)

Spain

c)

Australia

d)

Russia

15.

Why do we use if/else statements in JavaScript?

a)

To do something if a condition is true and do something else if the condition is false

b)

To repeat something for a fixed number of times

c)

To do some if the the condition is false only

d)

To repeat something while a condition is true

16.

Which of these is a valid Karel command?

a)

move();

b)

move()

c)

move;

d)

Move();

17.

Which type of programming language translates the entire code before running any of the instructions/steps?

a)

interpreted

b)

compiled

c)

scripting

d)

markup

18.

What will be printed as a result of the following code segment?

a)

Dylan

Jacob

b)

Jacob

Dylan

c)

Julia

Jacob

d)

Jacob

Julia

19.

Which data type is a number without a decimal component?

a)

char

b)

string

c)

integer

d)

float

20.

Text and numbers within " " in programming is called a:

a)

number

b)

word

c)

character

d)

string