Font size
WorksheetsAP CSP 2020 Midterm Review
Total questions: 16
Worksheet time: 16mins
Programs written with functions run more quickly
True
False
Functions can help remove repeated code from a program
True
False
Replacing repeated code with a function will reduce the number of commands the computer needs to run
True
False
Functions are called once but can be declared many times
True
False
Which of the following describes a conditional statement?
affects the sequential flow of control by executing different statements based on the value of a Boolean expression
stores information as a number, String, or Boolean
joins together two or more strings end-to-end to make a new string
an ordered sequence of characters
Which of the following describes a variable?
affects the sequential flow of control by executing different statements based on the value of a Boolean expression
stores information as a number, String, or Boolean
joins together two or more strings end-to-end to make a new string
an ordered sequence of characters
Which of the following describes concatenation?
affects the sequential flow of control by executing different statements based on the value of a Boolean expression
stores information as a number, String, or Boolean
joins together two or more strings end-to-end to make a new string
an ordered sequence of characters
Consider the code segment below:
var a = 0;
var b = 3;
var c = 4;
a = a+c;
b = a+c;
c = a+c;
What are the values of a, b & c after this code segment has been run?
a: 4 b: 4 c: 4
a: 4 b: 8 c: 8
a: 4 b: 8 c: 16
a: 0 b: 3 c: 4
Jan is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every time someone clicks the "addItemButton" she wants the variable to increase by 1.
var cartTotal = 0;
onEvent("addItemButton", "click", function(){
//<missing code>
console.log(cartTotal);
});
What code should Jan insert where it says <missing code> in order for her app to work?
cart Total = 1;
cartTotal + 1;
cartTotal = cartTotal + 1;
var cartTotal = cartTotal + 1;
var cartTotal + 1;
What is the output to the console after the following code segment is executed?
fiveMore();
function fiveMore(){
var x = 5;
}
var y = 3 + x;
console.log(y);
-2
3
5
8
Error. Unknown Identifier: x
Consider the following flow chart. Given that a = 5 and b = 10, what will be displayed by the program? (click on the image if it doesn't show up)
a is bigger
b
5
10
Nothing will be displayed
A Boolean expression is an expression that evaluates to which of the of the following?
Yes/Maybe/No
True/False
Any Integer
Integers between 1 and 10
Any single character
Consider the JavaScript code segment below. Which statement should be used in place of <missing code> such that the alarm is set to 9:00 am on weekends, and 6:30 am on weekdays. (click on the image if it doesn't show)
day == "Saturday"
day == "Sunday"
(day == "Saturday") || (day == "Sunday")
(day == "Saturday") && (day == "Sunday")
day != "Monday"
Something is wrong with the logic in the program. For which values of time will the greeting “Good Morning!” be displayed?
Any time between 6 and 9
Any time between 10 and 19
Any time between 0 and 20
There is no value of time that will result in “Good Morning!” being displayed
The logic error will cause the program to stop running at line 7.
Choose the two (2) Boolean expressions that evaluate to FALSE.
var temperature = 30;
(temperature > 0) && (temperature < 32)
(temperature == 0) || (temperature < 32)
(temperature != 0) && (temperature < 32)
(temperature == 0) || (temperature > 32)
(temperature < 0) || (temperature > 32)
What is the correct way to call this function?
function numbers ( ) {
console.log("1,2,3,4,5");
}
(a)
