Font size
WorksheetsAP Computer Science Principles Units 1, 2 & 3
Total questions: 44
Worksheet time: 22mins
What is the best explanation for why digital data is represented in computers in binary?
The binary number system is the only system flexible enough to allow for representing data other than numbers.
It's easier, cheaper, and more reliable to build machines and devices that only have to distinguish between binary states.
It typically takes fewer digits to represent a number in binary when compared to other number systems (for example, the decimal number system)
It's impossible to build a computing machine that uses anything but binary to represent numbers
What is the 4-bit binary number for the decimal number Ten (10)?
0010
1010
0110
0101
What is the minimum number of bits you would need to encode the 26 letters of the alphabet plus a space - a total of 27 characters?
2 Bits
3 Bits
5 Bits
6 Bits
Number systems with different bases such as binary (base-2) and decimal (base-10) are all used to view and represent digital data.
Which of the following is NOT true about representing digital data?
At one of the lowest levels of abstraction, all digital data can be represented in binary using only combinations of the digits zero and one.
The same value (number) can have a different representation depending on the number system used to represent it.
Groups of bits can be used to represent abstractions, including but not limited to numbers and characters.
Some large numbers cannot be represented in binary and can only be represented in decimal.
Consider the following three binary numbers:
01010 010000 1110
Which of the following lists the numbers in order from least to greatest?
010000, 1110, 01010
01010, 1110, 010000
01010, 010000, 1110
1110, 01010, 010000
A middle school is expanding to open a high school next year, doubling the total number of students. The school keeps a database in which each student's unique ID number is stored as an 8 bit number called studentID. Before the arrival of the new students almost every 8 bit number has already been assigned to a student. Of the options provided below, which is the smallest change to the way studentID is represented necessary to ensure each incoming student receives a unique ID?
Add a bit to studentID to double the number of IDs that the database can represent.
Double the number of bits in studentID to double the number of IDs that the database can represent
Keep using an 8-bit number for studentID but reserve the first bit to indicate middle school or high school.
Remove a bit from studentID to make room for incoming students
Which of the following is true about the way digital data is transmitted on the Internet?
Bit-rate (bandwidth) is the time elapsed between the transmission and receipt of a piece of digital data.
Latency is the amount of data (measured in bits) that can be sent in a fixed amount of time.
Digital data can only be transmitted between two devices when they are physically connected to one another (for example by a copper wire)
Two devices must communicate using the same bit-rate to successfully send and receive digital data.
8 bits is enough to represent 256 different numbers. How many total bits do you need to represent 512 (twice as many) numbers?
9 Bits
10 Bits
16 Bits
17 Bits
ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below.
ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the 8-bit binary value: 0100 0010
ASCII Character: A
ASCII Character: B
ASCII Character: D
The table does not contain the value represented by the binary number 0100 0010
Two students have developed a protocol in which they send 4-bit messages to each other. They decide to modify their protocol to start sending 8-bit messages instead. How many more values can be represented in an 8-bit message than a 4-bit message?
21 = 2 times as many values
22= 4 times as many values
23 = 8 times as many values
24 = 16 times as many values
Which of the following statements are true about routers and routing on the Internet. Choose two answers.
Protocols ensure that a single path between two computers is established before sending packets over it.
Routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic.
A packet traveling between two computers on the Internet may be rerouted many times along the way or even lost or "dropped".
Routers act independently and route packets as they see fit.
The various protocols in use on the internet are said to operate in layers in which the protocol(s) at each layer solve one problem related to networked communication, and higher layers are built on top of, and rely on, the lower layers to do their jobs.
From the list provided choose the two (2) answers that correctly describe which internet protocol relies on the other. For example: if protocol A relies on protocol B, it means that A is a higher level protocol than B, and thus protocol B must exist and work properly in order for protocol A to do its job.
Select two answers.
TCP/IP relies on HTTP
HTTP relies on TCP/IP
DNS relies on TCP/IP
TCP/IP relies on DNS
A school starts tracking which websites each computer in the school is visiting by monitoring the packets leaving the school. A sample of the information they have collected appears in this chart.
Which of the following is MOST likely to be answerable using all the data collected by this monitoring?
Which students are visiting social media sites from school
Which classes are assigning the most homework using the computers
Which programs students are running on the lab computers
Which websites are most frequently visited before and after school hours from a school computer
Which of the following BEST describes how protocols on the Internet (e.g. IP, TCP, HTTP) make use of abstraction to accomplish their respective purposes?
High level protocols take into account specific implementation details of lower level protocols to ensure they are compatible.
Low level protocols can provide functionality to high level protocols without revealing the details of how this is accomplished.
Low level protocols are written in binary while high level protocols are written in hexadecimal.
High level protocols can take on the role of a low level protocol in the event of failure in the system.
According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?
About.example.com
Example.co.uk
Example.com.org
Example.org
Which of the following is NOT true about TCP/IP packets?
Packets are numbered so if they arrive out of order the message can be reassembled.
TCP guarantees that no packets are ever dropped
Packets can be routed on different paths from sender to receiver.
Messages are broken into packets to improve reliability of the internet
The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IETF are:
An International coalition of government agencies who oversee the Internet in their countries.
A collection of the leaders of the Tier 1 Internet service providers.
A loosely organized collection of citizens and engineers.
Political leaders and heads of state.
There are no members. IETF is an "organization" in name only.
How does a computer resolve a domain name into an IP address?
It asks a DNS server for the corresponding IP address
It scans addresses until it finds the one it's looking for
It uses a Border Gateway Protocol to get the address from a nearby computer.
It creates an IP address for the domain, and shares it with the closest DNS.
The figure represents a network of physically linked computers labeled A through F. A line between two computers indicates that the computers can communicate directly with each other. Any information sent between two computers that are not directly connected must go through at least one other computer. The weight or cost of sending information from one computer to another is indicated by the number above the line.
For example, information can be sent directly between computers A, and B and will cost 5. Information sent between computers A and D must go through either computer C (with total cost 5), or through computer B (with total cost 8)
Question:
Computer A sends a packet intended to reach computer F. Along its path it arrives at Computer C. Which computer should Computer C forward the packet to in order to use the most cost effective path?
Computer A
Computer B
Computer D
Computer F
The world is currently in a transition to using IPv6, a newer version of the IP protocol that uses 128-bit addresses instead of 32-bit addresses used by IPv4. What is the main problem that IPv6 was created to solve?
32-bit addresses could not accommodate the increased size and amount of data traveling on the Internet as it has grown in popularity
IPv6 will allow problems with IPv4's address hierarchy to be resolved
IPv4 proved unreliable in some cases where network redundancy could not be ensured
32-bit addresses could not ensure that every internet-connected device can receive a unique IP address
Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem?
When the problem can be solved in a reasonable time and an approximate solution is acceptable
When the problem can be solved in a reasonable time and an exact solution is needed
When the problem cannot be solved in a reasonable time and an approximate solution is acceptable
When the problem cannot be solved in a reasonable time and an exact solution is needed
The colors of the pixels in a digital image are often represented by red, green, and blue values between 0 and 255 (an RGB triplet). A photographer is manipulating a digital image to lighten it because all of the RGB values in the image are less than 100, making it very dark. He does this by adding 20 to the R, G, and B values of each pixel, then overwriting the original image. What type of transformation is the photographer using on the digital image?
Lossless transformation
Lossy transformation
Multiband transformation
Chrome Sampling transformation
Which of the following is a true statement about data compression?
Data compression is only useful for files being transmitted over the Internet.
Regardless of the compression technique used, once a data file is compressed, it cannot be restored to its original state.
Sending a compressed version of a file ensures that the contents of the file cannot be intercepted by an unauthorized user.
There are trade-offs involved in choosing a compression technique for storing and transmitting data.
A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some videos being played more times than can be represented with 32 bits, the Web site is planning to change to 64-bit integers for the counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers?
2 times as many values can be represented.
32 times as many values can be represented.
2^32 times as many values can be represented.
32^2 times as many values can be represented.
Select the answer that lists the units of bytes in ascending order (from smallest to largest)
gigabyte, megabyte, terabyte
megabyte, terabyte, kilobyte
gigabyte, terabyte, megabyte
kilobyte, gigabyte, terabyte
An artist makes an RGB raster image in which each pixel color is encoded with 12-bits --- 4 bits each for red, green and blue.
Which of the following correctly shows the hexadecimal value for Red as a 12-bit representation.
F00
00F
FF00
FF0000
A compression scheme for long strings of bits called run-length encoding is described as follows:
Rather than record each 0 and 1 individually, instead record "runs" of bits by storing the number of consecutive 1s and 0s that appear.
Since it's binary, any run of 0s must be followed by a run of 1s (even if the run is only 1-bit long) and vice versa. Thus, you can store a list of small numbers that represents the alternating runs of 0s and 1s. The image above is an example:
To uncompress the data back into its original binary state, you simply reverse the process. This technique is an example of what type of compression?
Lossy compression
Lossless compression
Fast Fourier Transform compression
Tailored compression
Approximately how much bigger (how many more bytes) is a megabyte than a kilobyte?
1,000 times bigger
100,000 times bigger
1,000,000 times bigger
1,000,000,000 times bigger
A raw digital sound file samples a sound wave at some interval and measures the height of the wave at each point. Thus, raw sound is recorded as a list of numbers.
In very broad terms the MP3 audio compression algorithm identifies frequencies and volume levels - low and high - that are outside the range of human hearing and removes the data representing these frequencies from the original. This technique results in a smaller audio file that sounds exactly the same to the human ear.
This technique is an example of what type of compression?
Lossy compression
Lossless compression
Fast Fourier Transform compression
Tailored compression
The image below shows an encoding for a black and white pixel image. The first two bytes of the data (circled in red) are used to encode the width and height of the image.
What is the best term for this type of "data about the data"?
Megadata
Superdata
Metadata
Predata
Programming languages have some similarities and differences to the "natural" language you use in everyday speech. Select the two true statements about programming languages:
Ambiguities in natural language necessitate the creation of programming languages for controlling a computer
Compared to the number of words in a natural language, the number of defined words in a programming language is very small.
The number of defined words in a programming language is about the same as the number of words in a natural language.
There are typically many possible ways to interpret an instruction written in a programming language.
The next two questions use a robot in a grid of squares. The robot is represented as a triangle, which is initially facing up, towards the top of the grid. The robot is moved according to the instructions in the chart above.
Consider the following program which uses commands from the pseudocode described above.
REPEAT 4 TIMES {
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
ROTATE_RIGHT()
MOVE_FORWARD()
ROTATE_RIGHT()
MOVE_FORWARD()
ROTATE_RIGHT()
}
Which of the following images shows the path and ending location of the robot that will result from executing the code above. The starting location of the robot is shown as dotted triangle for cases where the robot does not start and end at the same location.
Consider the following incorrect program, which is intended to move the robot around the perimeter of a grid, as indicated by the drawing above. The starting position and direction of the robot is indicated in the diagram.
Line 1: REPEAT 4 TIMES
Line 2: {
Line 3: MOVE_FORWARD()
Line 4: ROTATE_RIGHT()
Line 5: MOVE_FORWARD()
Line 6: MOVE_FORWARD()
Line 7: MOVE_FORWARD()
Line 8: MOVE_FORWARD()
Line 9: ROTATE_RIGHT()
Line 10: }
Given the options below, which lines should be removed so the program will work as intended?
Line 3 and Line 4
Lines 5, 6, 7, 8 and 9
Line 8 and Line 9
Line 9
Which of the following is NOT true about functions in programming?
Functions are reusable programming abstractions.
Functions help reduce the complexity of writing and maintaining programs.
Functions cannot make calls to other functions within the same program.
Functions help break a problem into logical chunks.
Once defined, a function can be called many times from different parts of a program.
What is one important naming convention of functions?
A function name should indicate how long the function takes to run.
Two functions with similar behavior should be given identical names to indicate the relationship between them.
A function name should be as descriptive as possible to indicate what the function does.
Function names should be organized alphabetically.
The function name should begin with a number that indicates the order in which it should be executed.
Which one of the following statements about functions is TRUE
A function can change names over the course of a program.
Code can be added or removed dynamically from a function while the program is running.
Functions can be called using different names depending on where in the program they are called.
Two functions can be given identical names as long as their code is identical.
Two functions in a single program can have different names but contain identical code.
Which of the following will call the function drawStar?
drawStar;
drawStar();
function drawStar (){
for (var i=0; i<5; i++){
moveForward(100);
turnLeft(36);
}
}
function drawStar;
function drawStar();
For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions) to handle the task:
Drawing out the letters of a word "HELLO"
Loop
Function(s)
For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions) to handle the task:
Drawing 100 tiny dots in a line
Loop
Function(s)
For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions) to handle the task:
Drawing a circle of any size at any point on the screen
Loop
Function(s)
Why are parameters useful when programming?
Parameters determine the number of times the function will run.
Parameters allow for more flexible, generalized behaviors in functions.
Parameters are useful for teams of programmers because they help define the boundaries of the problem they are trying to solve.
Parameters change the order of operations within a function.
What is the most likely outcome of running the code shown in the image above?
It will draw a star with each side 150 pixels long.
The program will stop with an error at line 3 because parameters may not be used in for loops.
The program will stop with an error at line 5 because it is dividing by 0.
The program will run without error, but will not draw anything.
When programmers work together, what is an example of how abstraction in programming can promote collaboration?
Team members can rely on one another to explain their code.
Programmers can write functions without needing to know what they do or how they should work.
Programmers can use functions created by their partners, relying on the functionality without needing to know the specific details of how the function is implemented.
In order for programmers to work together, they must work in the same room.
Abstraction allows programmers to brainstorm more creative solutions to problems.
Which of the following images represents the most likely output produced by the code segment given above?
