wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Final/Midterm Review

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

In order to ask the user for input and store the result as a string, you should use the function called _

(a)  

2.

Most lines of code must end with a

a)

int

b)

string

c)

semicolon

d)

float

3.

A(n) _ variable can either take the value true or false.

(a)  

4.

A(n) _ is a series of steps or instructions that describe how to solve a problem.

a)

Algorithm

b)

readInt

c)

Karel

d)

float

5.

A(n) (a)   variable stores whole number

6.

Suppose you are writing a function that computes the area of a soccer field. Which of the following comments would be the best to use?

a)

//This is a function

b)

// This function computes the area

c)

//Computes and returns the are of a football field using the parameters of height and width

d)

This function doesnt need a comment

7.

The following if statement should check that an object will fit on the screen. The variables height and width store the height and width of the object. The variables screenHeight and screenWidth store the dimensions of the screen.

Which of the following pairs correctly fill in the condition for the if statement below?

a)

(height < screenHeight) && (width < screenWidth)

b)

(height < screenHeight) || (width < screenWidth)

c)

(height > screenHeight) || (width > screenWidth)

d)

(height > screenHeight) && (width > screenWidth)

8.

In which of the following scenarios would it be best to use a for loop?

a)

When you need to stop looping based on input from the user

b)

When you need to check that a user’s input is valid

c)

When you need to be able to use the block of code in many places in your program

d)

When you want to ask the user for 10 numbers

9.

In which of the following scenarios would it be best to use a while loop?

a)

When you need to loop as long as the user inputs even numbers

b)

When you need to get and store the user’s age

c)

When you need to find the average of 12 numbers

d)

When you need to change the color of one rectangle

10.

Why do programmers use variables?

a)

It allows the programmer to reuse multiple lines of code

b)

Because they are lazy and don’t want to write out equations every time

c)

To store values to easily reuse later and make code easier to read and understand

d)

They are a way to document functions

11.

Which of the following while loops will make Karel move until a wall is in the way?

a)

while(noBallsPresent()){

move();

}

b)

while(facingEast()){

move();

}

c)

while(frontIsBlocked()){

move();

}

d)

while(frontIsClear()){

move();

}

12.

Which of the following pairs of keywords correctly fills in the code below?

a)

while,if

b)

for, if

c)

while,else

d)

if, else

13.

Which of the following choices is a valid and useful variable name?

a)

myVariable

b)

joes___variable

c)

minNum

d)

2nd Number

14.

What is Top Down Design?

a)

Working from the top of your program and coding down to the bottom

b)

Starting with the biggest problem and then working down to solve the more specific problems

c)

Implementing all of the functions first, then putting them together in the start function

d)

Starting with the most specific problems and then working up to solve the big problem

15.

What would be the output of the following program?

a)
b)
c)
d)