wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Intro to Programming - AP CSP Unit 2 Review

Total questions: 20

Worksheet time: 40mins

Name
Class
Date
1.

Chad has written the majority of his code in Scratch and is ready to start thinking of test cases to make sure that his program functions properly, and when issues arise, fix them. Chad is also going to show his program to his classmate and ask for any feedback or changes he could add to make his program better. This process is known as what?

a)

Iterative Development Process

b)

Debugging

c)

Pseudocode

d)

Program Detection

2.

Which of the below options would be the best set of instructions to give for a program designed in Scratch?

a)

Make your way through the maze! Avoid the brain-eating zombies and be sure to collect the “hearts” for extra lives. Good Luck!

b)

Dodge zombies, gain lives, all while trying to make it through the maze! Click start to begin your exciting adventure.

c)

Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the “hearts” for more lives and avoid being eaten by zombies.

d)

Ready, set, RUN!!!!! Use your skills and intelligence to weave your way through the maze, avoiding obstacles and prove that you’ve got what it takes to survive!

3.

Which of the following would be the most appropriate name for a variable?

a)

variable1

b)

t

c)

amountOfTimeRemainingInTheGame

d)

time_left

4.

Consider the image above.


Which of the following values is displayed if the user inputs the following list of values for each prompt:

1 2 3 4 5 6 7 8 9 15

a)

3

b)

4

c)

5

d)

6

5.

Assuming that before this code is run, x = 1. What would be displayed at the end?

a)

210

b)

16

c)

8

d)

1

6.

What condition will make the following an infinite loop?

a)

y = -108

b)

y ≠ -3

c)

y ≥ 8

d)

y < -53

7.

If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

a)

Is anyone there?

b)

Better late than never.

c)

Hello. Is anyone there?

d)

Hello. Better late than never.

8.

The block of code is supposed to display "Multiple of 5" if the positive number value is in fact a multiple of 5.


Which of the following could be used in place of missing condition so the code will execute as intended?

a)

(value MOD 1) = 5

b)

(value MOD 5) = 1

c)

(value MOD 0) = 5

d)

(value MOD 5) = 0

9.

Which of the following describes the output of the following code segment?

a)

The word HI could be displayed 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times

b)

The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 times

c)

The word HI could be displayed 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 times

d)

The word HI could be displayed 1, 2, 3, 4, 5, 6, 7, 8, or 9 times

10.

What values, when input by the user, of A, B and C will display "Invalid Input"?

a)

A = -10 B = 0 C = 4

b)

A = 0 B = 0 C = 0

c)

A = -1 B = -2 C = 0

d)

A = -5 B = 0 C = 0

11.

he volume of a rectangular prism is calculated by multiplying its length, width and height. What could be substituted into the section of the code marked < missing code > that would accurately calculate the volume based on the user input of l, w and h?

a)

l x w x h

b)

l * w * h

c)

l (w) (h)

d)

l / w / h

12.

What starting value of n would make this portion of the program repeat the block of code

below the most amount of times?

a)

1

b)

2

c)

3

d)

4

13.

What would be the most appropriate substitute for the missing Boolean Operator if the intention is to display"True" for only values of x between, but not equal to values of 0 and 10?

a)

NOT

b)

AND

c)

OR

d)

XOR

14.

For what values of x and y, when input into the program below, will the output display Right Right?

a)

x must be 0 and y must be a positive number

b)

x cannot be 0 and y must be a negative number

c)

x and y must both be equal to 0

d)

No values of x and y will display "Right Right"

15.

For which of the follow grids will the code correctly navigate the robot to the final destination of the gray square?

a)
b)
c)
d)
16.

This is a section of code taken from a larger program.


What outputs should be substituted in for "missing output 1" and "missing output

a)

missing output 1: value is equal to 4

missing output 2: value does not equal 4

b)

missing output 1: value does not equal 4

missing output 2: value is equal to 4

c)

missing output 1: value does not equal 4

missing output 2: value is greater than 4

d)

missing output 1: value does not equal 4

missing output 2: value does not equal 4

17.

Which of the following is true?

a)

In an IF / ELSE selection structure, one of the sections must run, either the IF or the ELSE portion

b)

A loop always has to execute at least once

c)

An IF selection structure will not execute when the condition is true

d)

None of the above are true

18.

Which of the following are true about programming documentation?

Select two answers:

a)

It is useful to other programmers that view your code, so that they can understand what different parts of the code are intended to do.

b)

It is needed when working in a group dynamic, but not very beneficial to the programmer when they are working alone.

c)

It allows the programmer an opportunity to attribute help, work and code from others.

d)

It should be written only at the end of the program, after you have thoroughly tested all aspects of your code.

19.

A student developed a program that outputs the name of a fruit that begins with a letter, dependent upon the variablekeyPressed, which stores the letter (from A to Z only) a user types on the keyboard. Above is a section of code from her program:


Which of the following descriptions below would be a way that this student might have written the rest of her code so that it executes as intended?


Select two answers.

a)

Use 25 nested if/else blocks where the if portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and the else simply holding the next if portion until the last else, which displays a fruit that begins with Z.

b)

Take the above code and insert it into a Repeat block that repeats 26 times.

c)

Use 26 if/else blocks where the if portion is formatted like the code segment above (changing the letters of the alphabet and fruits) and each else portion displays "You did not choose this letter".

d)

Use 26 if blocks formatted similarly to the one above (changing the letters of the alphabet and fruits).

20.

The image uses a robot in a grid of squares. The robot is represented by a triangle and is in the upper left corner facing toward the bottom of the grid.


Which blocks of code will properly navigate the robot to the final destination of the grey square in the bottom right corner of the grid without making it run into the wall or a black square?


Select two answers.

a)
b)
c)
d)