Font size
WorksheetsAP CSP - Unit 4 Code.org Review
Total questions: 44
Worksheet time: 31mins
What is it when a function is used within your code - this likely happens multiple times in a program?
called
declared
created
defined
What is it called when you define a function?
called
declared
created
typed
What is happening in this code?
the variables are being created
the function updateScreen is being declared
the function updateScreen is being called
the function updateScreen is being updated
What is happening in this code?
the variables are being created
the function singChorus is being declared
the function singChorus is being called
the function singChorus is being updated
What are the benefits of creating functions?
There is more than one answer.
removing repeated code
keeping code organized
allowing programmers to be lazy
making it harder for people to read your code
makes it easier to update your code
Categorize these items.
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
You should only use var once per variable because otherwise it could cause errors in your program.
True
False
You should create functions at the top of your program and variables at the bottom of your program.
True
False
You should create variables outside of onEvents.
True
False
Which part of this code could be made into a function? (There are two areas)
It is best if you declare functions during code creation or before you write your program.
True
False
What will be the order of the numbers printed in the console when this program is run?
3 7 10 3 7 10
3 10 7
3 10 7 10 7
3 7 10
Organize these options into the right categories.
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
What are values?
numbers, strings, or booleans
fancy name for add, subtract, divide, multiple
named group of programming instructions, also called a procedure
refers to the remainder
What is an expression?
numbers, strings, or booleans
combination of operators and values that evaluate to a single value
named group of programming instructions, also called a procedure
affects how the program runs depending on different statements that are based on Boolean values
What is a variable?
numbers, strings, or booleans
combination of operators and values that evaluate to a single value
fancy name for addition, subtraction, multiplication, and division
portion of the code and program that can hold a value
What are operators?
numbers, strings, or booleans
combination of operators and values that evaluate to a single value
fancy name for addition, subtraction, multiplication, and division
portion of the code and program that can hold a value
What is a mod?
refers to the remainder
combination of operators and values that evaluate to a single value
fancy name for addition, subtraction, multiplication, and division
portion of the code and program that can hold a value
Match the following.
&&
AND
| |
OR
!
NOT
Thinking about truth tables, what does this set of logical operators evaluate to?
TRUE && FALSE
True
False
Thinking about truth tables, what does this set of logical operators evaluate to?
TRUE | | FALSE
True
False
Thinking about truth tables, what does this set of logical operators evaluate to?
! TRUE
True
False
What is the value of 12 % 6?
2
0
3
1
What type of variable is this?
Not a variable
variable with concatenation
variable with counter pattern
variable string
What type of variable is this?
Not a variable
variable with concatenation
variable with counter pattern
variable string
\n means to add something to a new line in your program
True
False
What does 6 % 4 evaluate to?
0
1
2
3
Once this code is run, what is the value of tickets?
68
103
35
33
What will be displayed after this code is run?
You Lose!
Perfect Game!
You Win!
<-- is written as = in Javascript.
True
False
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?
Foxtrot
Hotel
November
Yankee
What number will be output by the console.log command on line 7?
10
20
100
200
"You win!" never displays. What change would fix this issue?
Line 1 - change the variable name to totalScore.
Line 3 - remove var.
Line 4 - change the conditional to >= 5.
Line 5 - change to a getText command.
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?
Boolean
Number
String
List
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 simulation of flipping a coin
A simulation of rolling a fair die (with sides numbered 1 through 6)
A simulation of the temperature in a location over time
A simulation of traffic patterns on a road
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?
((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)
((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)
((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)
((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)
Match the following
15 % 3
0
5 % 3
2
16 % 3
1
13 % 8
5
What is a parameter in a function?
input value to a function for the function’s execution
a variable used to send information to a function
the name of the function
the name of the main program calling the function
Consider the line of code:
Label('Go Team', 200, 100)
What is the Label?
argument
parameter
function name
An extra piece of information passed to a function to customize it for a specific need
Conditional
Parameter
Variable
Abstraction
a variable used as a place holder for a value passed to a function
parameter
argument
a value passed to a function
parameter
argument
When defining a function, the definition must occur before it is called.
true
false
