wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP 12-2 U4L1 Variable

Total questions: 9

Worksheet time: 16mins

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 text will be output by the program?

a)

less than 10

b)

less than 20

c)

less than 30

d)

30 or more

3.

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

4.

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)

5.

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

6.

Evaluate:


10 / 2 evaluates to

a)

1

b)

0.5

c)

2

d)

5

7.

What is the result of running this program and clicking on a buttonUp button 20 times?

00 var Count

01 Count = 0

02 onevent(buttonUp, Click), Count = Count + 1

a)

Count = 0

b)

Count = 19

c)

Count = 20

d)

Count = Undefined

8.

Assume that the two variables age and day have been initialized with the values shown.

var age = 16;

var day = "Monday";


Determine if the following statement evaluates to true or false.

(age > 10) && (age < 20)

a)

true

b)

false

9.

Assume that the two variables age and day have been initialized as shown below.


var age = 16;

var day = "Monday";


Determine if the following statement evaluates to true or false.


(day == "Tuesday") || (age < 12)

a)

true

b)

false