AP CSP 12-2 U4L1 Variable

AP CSP 12-2 U4L1 Variable

9th - 12th Grade

9 Qs

quiz-placeholder

Similar activities

Copyright Quiz Stolen from eff.org

Copyright Quiz Stolen from eff.org

9th - 12th Grade

14 Qs

UNIT 1.8 ELCE

UNIT 1.8 ELCE

10th Grade

14 Qs

Access - Lesson 14

Access - Lesson 14

9th - 12th Grade

10 Qs

ICT 10 : Introduction to Adobe Illustrator(CS5)

ICT 10 : Introduction to Adobe Illustrator(CS5)

10th Grade

10 Qs

Wee Word Intro

Wee Word Intro

7th - 12th Grade

12 Qs

Data Structures: Linked Lists and Hashtables

Data Structures: Linked Lists and Hashtables

11th Grade - University

14 Qs

Email Quiz

Email Quiz

9th Grade

10 Qs

TCP/IP & other protocols [A Level]

TCP/IP & other protocols [A Level]

12th Grade

14 Qs

AP CSP 12-2 U4L1 Variable

AP CSP 12-2 U4L1 Variable

Assessment

Quiz

Computers

9th - 12th Grade

Easy

Created by

Adam Perry

Used 2+ times

FREE Resource

AI

Enhance your content

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

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

10

100

20

200

Answer explanation

The variable bop is initialized on line 2. On line 3, the variable bop is assigned the value 10. On line 5, the variable bop is assigned the value 100. Since the most recent value bop has been assigned is 100, that is the value that will be printed by the command on line 7.

2.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

Media Image

What text will be output by the program?

less than 10

less than 20

less than 30

30 or more

Answer explanation

Walking through the program line by line:

On line 1, the variable score is initialized and assigned the value 0.

On line 2, the variable score is assigned its current value (0) plus 10. On line 3, the variable score is assigned its current value (10) plus 10. On line 4, the variable score is assigned its current value (20) plus 10.

On line 5, the boolean expression score < 10 evaluates to false since the current value of score is 30, which causes the command on line 6 to not execute.

On line 7, the boolean expression score < 20 evaluates to false since the current value of score is 30, which causes the command on line 8 to not execute.

On line 9, the boolean expression score < 30 evaluates to false since the current value of score is 30, which causes the command on line 10 to not execute.

Since all of the if-else-if statements have evaluated to false, the command inside the else statement will run and the console prints 30 or more.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

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

a b c

a b c b c b c

a b c b c

a b c a

Answer explanation

Line 1 will print out a, line 2 calls the function letters which will print b then c. Line 3 calls the function letters agan which will print b then c.

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

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.

Media Image
Media Image
Media Image
Media Image

Answer explanation

There are multiple ways to write this conditional statement so that it correctly decides the price for each ticket. C is the only one of these choices that accomplishes that. Options A and B will assign a ticket price of $8 to anyone over the age of 12, including those 65 and older. Option D will assign a ticket price of $8 to everyone under the age of 65, including those 12 and younger.

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

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

1

2

3

4

Answer explanation

Media Image

6.

MULTIPLE SELECT QUESTION

1 min • 1 pt

Evaluate:


10 / 2 evaluates to

1

0.5

2

5

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

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

Count = 0

Count = 19

Count = 20

Count = Undefined

8.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

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)

true

false

9.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

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)

true

false