WorksheetsAP CSP Review Semester 1 (22-23)
Total questions: 51
Worksheet time: 50mins
Which character, represented in binary as a byte, contains the most zeros?
I. Physical Internet (wires, cables, etc.)
II. HTTP
III. TCP
IV. IP
Lossless and lossy compression are present in many different file formats (image, music, video, etc.). The graphic below illustrates how the two compression formats work. Which of the following statements below is NOT true?
All lossless compression is based on the idea of breaking a file into a smaller form for transmission or storage and then being put back together in its entirety.
Lossy formats are excellent to use when a file must be compressed and rebuilt to its exact pre-compressed specifications.
Scanning in a picture creates a lossy format result. The program gives you its interpretation of the original.
Moving music onto your digital music player is done in a lossless format to reduce the size of the file.
Step 1: Assign random values between 1 and 6 to Cubel.
Step 2: If sum is greater than 10, display “Winner!”.
Step 3: Display sum.
Step 4: If the sum is less than or equal to 10, display “Loser”.
Step 5: Assign random values between 1 and 6 to Cube2.
Step 6: Assign the value of Cubel + Cube2 to sum.
DNS relays packet information.
HTTP translates the name of a web server to a valid IP address.
HTTP relays packet information.
TCP/IP translates the name of a web server to a valid IP address.
HTTP relays packet information.
DNS translates the name of a web server to a valid IP address.
TCP/IP relays packet information.
DNS translates the name of a web server to a valid IP address.
Consider the following code:
var a = 0
var b = 2
var c = 6
a = a+b
b=a+c
c=a+b
What are the values of a, b, and c after this code segment has been run?
a= 0 b=2 c=6
a=2 b=6 c=2
a=2 b=2 c=8
a= 2 b=8 c=10
What is displayed by the console.log statement after the following code?
var a = 2
var b = 4
var c = 10
a = b/a
b = c-a
c = b/a
console.log("value is: " + c)
value is: 2
value is: 4
value is: 6
value is: 10
This is used to compare two values, and returns a Boolean (true/false)
Local Variable
Global Variable
==
=
Which prompt tells the computer to move to a new line for a string output.
\newLine
\new
\n
\next
y = 3;
x = 5 * y;
x++;
list = [1,2,3,4,5]; What would the list look like if we execute the code below? list.append(6);
an ordered collection of elements
index
element
list
a common method for referencing the elements in a list or string using numbers
index
element
lists
infinite loop
occurs when the ending condition will never evaluate to true
infinite loop
element
sampling
overflow error
process of accessing each item in a list one at a time
iteration
traversal
lossy compression
lossless compression
list = [1,2,3,4,5]; What is the highest index in this list?
Which of the following will result in all the items in list being printed to the console if placed where the program reads <INSERT CODE> and the program is run?
i < list[list.length]
i < list.length
i < list[0]
i < list[1]
wordList is a list of words that currently contains the values ["tree", "rock", "air"]
Which of the following lines will result in the list containing the values ["air", "rock", "air"]
wordList[0] = wordList[2]
wordList[2] = wordList[0]
insertItem(wordList, 0, "air")
removeItem(wordList,0)
What will be displayed in the console when this program runs?
var numList = [10,20,30];
console.log(numList[numList.length-1]);
2
3
20
30
What will be displayed when this program finishes running?
var numbersList = [20, 10, 5]
appendItem(numbersList, 50)
appendItem(numbersList,100)
removeItem(numbersList,1)
insertItem(numbersList, 0, 30)
console.log(numbersList.length)
3
6
7
5
What will be displayed in the console when the following program runs?
0
2
4
6
0
2
4
2
4
6
The program will result in an infinite loop
What will the following program display in the console?
0
1
2
3
0
1
2
3
4
1
2
3
1
2
3
4
What will the following program display in the console?
0
5
10
15
The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing up.
Which of the following programs will move the robot to the gray square following the path shown on the grid?
If the program above is run, what will be displayed in the console?
[apple, dream]
[bug, car, ear]
[bug, car, ear, food]
[apple, dream, food]
A program is designed to determine the minimum value in a list of positive numbers called numList. The following program was written. Which of the following can be used to replace <MISSING CODE> so that the program works as intended for every possible list of positive numbers?
0
1000000
numList.length
numList[0]
A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails". The program below simulates randomly flipping that coin many times. Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?
tails has a value of 0 and heads has a value of 100
tails has a value of 100 and heads has a value of 0
tails has a value of 20 and heads has a value of 20
tails has a value of 50 and heads has a value of 50
A restaurant knows from historical data that 60 out of 100 of its customers purchase a full meal while 40 out of 100 only order a side dish. The program below is intended to simulate the orders of 1000 customers. Which of the following can be used to replace <MISSING CODE> so that the simulation works as intended?
random(1,100) = 40
random(1,100) = 60
random(1,100) <= 40
random(1,100) <= 60
What does HTTP stand for?
Hypertalk Talking Protocol
HyperText Transmission Protocol
Hypertext Transferable Protocol
HyperText Transfer Protocol
What is the RGB value of red?
(255,0,0)
(255,0,255)
(255,255,0)
(0,0,255)
Given the above code segment, what would be displayed if age were initialized with a value of 18?
group 1
group 2
group 1 group 2
Nothing will be displayed
Consider the above code.
Assuming that before this code is run, x = 1. What would be displayed at the end?
210
16
8
1
What condition will make the above an infinite loop?
y = -108
y≠-3
y ≥ 8
y < -53
Consider the above code segment.
Which of the following best describes the result of running the code segment?
The number 0 is displayed.
The number 4 is displayed.
The number 10 is displayed.
Nothing is displayed; the program results in an infinite loop.
ASCII is a character-encoding scheme that uses 7 bits (8 bits if you are using the extended ASCII table) to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table above.
Which ASCII character is represented by the binary (base 2) number 1000001?
A
B
C
D
