wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

AP CSP Unit 4

Total questions: 15

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

What number will be output by the console.log command on line 7?

a)

10

b)

100

c)

20

d)

200

2.

What number will be output by the console.log command on line 5?

a)

10

b)

11

c)

12

d)

13

e)

16

3.

What number will be output by the console.log command on line 5?

a)

10

b)

25

c)

30

d)

35

4.

What text will be output by the program?

a)

less than 10

b)

less than 20

c)

less than 30

d)

30 or more

5.

What text will be output by the program?

a)

Output A

b)

Output B

c)

Output C

d)

Output D

e)

Output E

6.

What will be the order of letters printed to the console when this program is run?

a)

a b c

b)

a b c b c b c

c)

a b c b c

d)

a b c a

7.

"You win!" never displays. What change would fix this issue?

a)

Line 1 - change variable name to totalScore

b)

Line 3 - remove var

c)

Line 4 - change conditional to score >= 5

d)

Line 5 - change to a getText command

8.

When this function is called, the smaller of two numbers is displayed. What Boolean expression would not work in line 12 in order to accomplish this goal?

a)

b)

c)

d)

9.

This function chooses the screen to display based on the score. What is the correct way to call this function?

a)

b)

c)

d)

10.

There is repeated code in these onEvent blocks. Choose the correct code for the updateScreen() function which would be called in each of the onEvent blocks.

a)

b)

c)

d)

11.

A movie theater charges different ticket prices based on a customer's age. The prices are shown in the table below.

The customer's age is stored in the variable age and the price is stored in the variable price. Which piece of code will correctly decide the price for each ticket.

a)

b)

c)

d)

12.

A museum charges different prices based on the day of the week and age of the visitor. The pricing rules are shown below.

On Tuesday and Thursday children 10 and under get in free ($ 0).

For all other days and ages the cost is ten dollars ($ 10).

The visitor's age is stored in the variable age, the day of the week is stored in a variable day, and the price in dollars is stored in the variable price. Which piece of code will correctly decide the price for each ticket.

a)

b)

c)

d)

13.

What will the value of the variable bags be at the end of the flowchart shown here?

a)

1

b)

2

c)

3

d)

4

14.

Choose the correct definition for Conditional Statement

a)

affects the sequential flow of control by executing different statements based on the value of a Boolean expression

b)

stores information as a number, String, or Boolean

c)

joins together two or more strings end-to-end to make a new string

d)

an ordered sequence of characters

15.

Which of the following is true of functions?

a)

Programs written with functions run more quickly

b)

  Functions can help remove repeated code from a program

c)

Replacing repeated code with a function will reduce the number of commands the computer needs to run

d)

Functions are called once but can be declared many times