wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP - Unit 4 Code.org Review

Total questions: 44

Worksheet time: 31mins

Name
Class
Date
1.

What is it when a function is used within your code - this likely happens multiple times in a program?

a)

called

b)

declared

c)

created

d)

defined

2.

What is it called when you define a function?

a)

called

b)

declared

c)

created

d)

typed

3.

What is happening in this code?

a)

the variables are being created

b)

the function updateScreen is being declared

c)

the function updateScreen is being called

d)

the function updateScreen is being updated

4.

What is happening in this code?

a)

the variables are being created

b)

the function singChorus is being declared

c)

the function singChorus is being called

d)

the function singChorus is being updated

5.

What are the benefits of creating functions?
There is more than one answer.

a)

removing repeated code

b)

keeping code organized

c)

allowing programmers to be lazy

d)

making it harder for people to read your code

e)

makes it easier to update your code

6.

Categorize these items.

Categorize the following

a named group of programming instructions

also known as a procedure

a command that executes the code within a function

should only occur once

can be used multiple times in a program

Functions
Function call
7.

You should only use var once per variable because otherwise it could cause errors in your program.

a)

True

b)

False

8.

You should create functions at the top of your program and variables at the bottom of your program.

a)

True

b)

False

9.

You should create variables outside of onEvents.

a)

True

b)

False

10.

Which part of this code could be made into a function? (There are two areas)

11.

It is best if you declare functions during code creation or before you write your program.

a)

True

b)

False

12.

What will be the order of the numbers printed in the console when this program is run?

a)

3 7 10 3 7 10

b)

3 10 7

c)

3 10 7 10 7

d)

3 7 10

13.

Organize these options into the right categories.

Categorize the following

Holds one value

Includes strings, numbers, and booleans

Reference that can be used repeatedly and its value can be changed throughout a program

Affects the way the program is run based on different boolean values

If-the-else statements

Variables
Conditionals
14.

What are values?

a)

numbers, strings, or booleans

b)

fancy name for add, subtract, divide, multiple

c)

named group of programming instructions, also called a procedure

d)

refers to the remainder

15.

What is an expression?

a)

numbers, strings, or booleans

b)

combination of operators and values that evaluate to a single value

c)

named group of programming instructions, also called a procedure

d)

affects how the program runs depending on different statements that are based on Boolean values

16.

What is a variable?

a)

numbers, strings, or booleans

b)

combination of operators and values that evaluate to a single value

c)

fancy name for addition, subtraction, multiplication, and division

d)

portion of the code and program that can hold a value

17.

What are operators?

a)

numbers, strings, or booleans

b)

combination of operators and values that evaluate to a single value

c)

fancy name for addition, subtraction, multiplication, and division

d)

portion of the code and program that can hold a value

18.

What is a mod?

a)

refers to the remainder

b)

combination of operators and values that evaluate to a single value

c)

fancy name for addition, subtraction, multiplication, and division

d)

portion of the code and program that can hold a value

19.

Match the following.

a)

&&

1.

AND

b)

| |

2.

OR

c)

!

3.

NOT

20.

Thinking about truth tables, what does this set of logical operators evaluate to?

TRUE && FALSE

a)

True

b)

False

21.

Thinking about truth tables, what does this set of logical operators evaluate to?

TRUE | | FALSE

a)

True

b)

False

22.

Thinking about truth tables, what does this set of logical operators evaluate to?

! TRUE

a)

True

b)

False

23.

What is the value of 12 % 6?

a)

2

b)

0

c)

3

d)

1

24.

What type of variable is this?

a)

Not a variable

b)

variable with concatenation

c)

variable with counter pattern

d)

variable string

25.

What type of variable is this?

a)

Not a variable

b)

variable with concatenation

c)

variable with counter pattern

d)

variable string

26.

\n means to add something to a new line in your program

a)

True

b)

False

27.

What does 6 % 4 evaluate to?

a)

0

b)

1

c)

2

d)

3

28.

Once this code is run, what is the value of tickets?

a)

68

b)

103

c)

35

d)

33

29.

What will be displayed after this code is run?

a)

You Lose!

b)

Perfect Game!

c)

You Win!

30.

<-- is written as = in Javascript.

a)

True

b)

False

31.

In the program, the initial value of the x is 5 and the
initial value of y is 10.

What is displayed after the program is run?

a)

Foxtrot

b)

Hotel

c)

November

d)

Yankee

32.

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

a)

10

b)

20

c)

100

d)

200

33.

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

a)

Line 1 - change the variable name to totalScore.

b)

Line 3 - remove var.

c)

Line 4 - change the conditional to >= 5.

d)

Line 5 - change to a getText command.

34.

The variable age is to be used to represent a person’s age, in years. 
Which of the following is the most appropriate data type for age?

a)

Boolean

b)

Number

c)

String

d)

List

35.

A student is writing a program to model different real-world events using simulations.

Which of the following will generate a result that would best be stored using a Boolean variable?


a)

A simulation of flipping a coin

b)

A simulation of rolling a fair die (with sides numbered 1 through 6)

c)

A simulation of the temperature in a location over time

d)

A simulation of traffic patterns on a road

36.

To attend a particular camp, a student must be either at least 13 years old or in grade 9 or higher,

but must not yet be 18 years old.

Let age represent a student’s age and let grade represent the student’s grade level.

Which of the following expressions evaluates to true if the student is eligible to attend the camp and evaluates to false otherwise?

a)

((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)

b)

((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)

c)

((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)

d)

((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)

37.

Match the following

a)

15 % 3

1.

0

b)

5 % 3

2.

2

c)

16 % 3

3.

1

d)

13 % 8

4.

5

38.

What is a parameter in a function?

a)

input value to a function for the function’s execution

b)

a variable used to send information to a function

c)

the name of the function

d)

the name of the main program calling the function

39.
A function;
a)
Expresses a true false statement
b)
can contain letters, numbers, spaces, and symbols.
c)
takes in an input, does something with it, and then returns an output.
d)
Runs a boolean (true/false) statement based on data entered
40.

Consider the line of code:

Label('Go Team', 200, 100)

What is the Label?

a)

argument

b)

parameter

c)

function name

41.

An extra piece of information passed to a function to customize it for a specific need

a)

Conditional

b)

Parameter

c)

Variable

d)

Abstraction

42.

a variable used as a place holder for a value passed to a function

a)

parameter

b)

argument

43.

a value passed to a function

a)

parameter

b)

argument

44.

When defining a function, the definition must occur before it is called.

a)

true

b)

false