wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

IST CodeHS Unit 7 Programming Concepts Review

Total questions: 22

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of IF statement #1?

a)

If there is a ball at the current location, pick it up

b)

If there is no ball at the current location, put one down

c)

If the front is clear, move forward

d)

If there is a ball at the last location, pick it up

2.

What is wrong with this Karel command? Select all that apply: Move;

a)

this command is correct

b)

it should have a lower case m

c)

it should have parentheses

d)

it should not have a semi-colon ;

3.

What is wrong with this code? Select all that apply:

a)

the function name should be Start()

b)

the move() command is undefined

c)

the go() function is undefined

d)

the go() function is called twice in a row

4.

How many tennis balls will Karel put down in this program?

a)

4

b)

5

c)

6

d)

0

5.

What is the best way to define a function that turns Karel around at the same location?

a)

function turnAround() { turnLeft(); turnLeft(); }

b)

function turn() {

turnLeft();

turnRight(); }

c)

function turnAround() {

turnRight();

turnRight();

turnRight(); }

d)

turnAround function() {

move();

turnLeft();

move(); }

6.

What is the correct way to write a single line comment in JavaScript?

a)

//comment

b)

/* this is a multi-

* line comment

* using JS

*/

c)

#comment

d)

this is a comment

7.

Which of these is a valid Karel command?

a)

turnLeft();

b)

turnBack();

c)

goForward();

d)

goLeft();

8.

What control structure should we use if we want Karel to move and turn left 8 times in a row?

a)

For loop

b)

While loop

c)

If statement

d)

Function

9.

How should a For loop that is meant to repeat an action 10 times be written in JavaScript?

a)

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

b)

for (i=0, i<10, i++) { }

c)

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

d)

for (i=10, i<0, i++) { }

10.

If Karel starts at Row 2, Column 1 facing South, where will Karel end up and what direction will she be facing after running this code?

a)

Karel will crash into the wall at Row 1, Column 1, Facing South

b)

Row 1, Column 1, Facing East

c)

Row 2, Column 1, Facing North

d)

Row 1, Column 2, Facing West

11.

Karel begins at Row 4, Column 4 facing East. What is her ending location and direction after running the code?

a)

Row 4, Column 6, Facing North

b)

Row 3, Column 5, Facing South

c)

Row 4, Column 6, Facing East

d)

Row 3, Column 6, Facing West

12.

Karel begins at Row 2, Column 3 facing North. What is her ending location and direction after running the code?

a)

Row 4, Column 4, Facing East

b)

Row 2, Column 4, Facing West

c)

Row 4, Column 2, Facing West

d)

Karel crashes into a wall

13.

Assume Karel is a 5 x 5 world (5 Rows and 5 Columns). What location describes the center of this world?

a)

Row 3, Column 3

b)

Row 2, Column 2

c)

Between Rows 2 and 3, and between Columns 2 and 3

d)

Row 4, Column 4

14.

Assume you want Karel to move around the edge of a world, but you don't know the size of the world. (Example: it might be 5 x 5 or maybe 10 x 10) What control structure would work best to accomplish the continuous movement?

a)

For loop

b)

While loop

c)

If statement

d)

If/Else statement

15.

What is a benefit of using well-named and well-defined functions in a program?

a)

It makes the code more understandable and avoids repeated code

b)

It makes the code more understandable and the program will run faster

c)

It avoids repeated code and therefore makes the program run faster

d)

It avoids syntax errors and makes the code more readable

16.

What is a good Postcondition comment for this function?

a)

Karel is one spot above a tennis ball facing East

b)

Karel is on a spot with a tennis ball facing East

c)

Karel goes around the tennis ball facing East

d)

Karel is on a spot with a tennis ball facing North

17.

If we call the stairStep function and then put a tennis ball down and repeat those actions 5 times, what kind of shape will we make?

a)

A diagonal line of 5 tennis balls going North-East

b)

A straight horizontal line of 5 tennis balls

c)

A straight vertical line of 5 tennis balls

d)

A diagonal line of 5 tennis balls going South-East

18.

If Karel begins at Row 1, Column 2 facing East and the stairStep function is called twice, what will be Karel's final position and direction?

a)

Row 3, Column 4, Facing East

b)

Row 2, Column 3, Facing North

c)

Row 4, Column 3, Facing East

d)

Row 2, Column 4, Facing North

19.

What condition should be checked in a While loop to get Karel to pick up all the tennis balls at the current location?

a)

ballsPresent()

b)

noBallsPresent()

c)

frontIsClear()

d)

leftIsBlocked()

20.

What condition should be checked to see if there is a wall (hurdle) in front of her?

a)

frontIsClear()

b)

frontIsBlocked()

c)

facingEast()

d)

facingNorth()

21.

Which of the following is an example of low-level abstraction? Note: The task being described is getting dressed in the morning.

a)

I put on my clothes

b)

I put on a shirt, pants, and shoes

c)

I put on a dress and shoes and combed my hair

d)

I put my left arm through the left arm-hole, then I put my right arm through the right arm-hole, then I put my head through the top of the shirt...

22.

What is the purpose of putting comments in a program?

a)

Comments are necessary for the program to execute properly

b)

Comments are an important part of for loop syntax

c)

Comments are not necessary in a computer program

d)

Meaningful comments help communicate what the program (or function) does to yourself and to other programmers