wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Science Principles End-of-Year Exam

Total questions: 28

Worksheet time: 56mins

Name
Class
Date
1.

A student wrote the following code for a guessing game  

While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction win←true somewhere in the code.   Where could win←true be inserted so that the code segment works as intended?  

a)

Between line 6 and line 7

b)

Between line 9 and line 10

c)

Between line 20 and 21

d)

Between line 21 and 22

2.

Participants in a survey were asked how many hours per day they spend reading, how many hours per day they spend using a smartphone, and whether or not they would be interested in a smartphone application that lets users share book reviews. 

The data from the survey are represented in the graph below. Each × represents a survey participant who said he or she was interested in the application, and each O represents a participant who said he or she was not interested.  

Which of the following hypotheses is most consistent with the data in the graph?  

a)

Participants who read more were generally more likely to say they are interested in the application.

b)

Participants who read more were generally less likely to say they are interested in the application.

c)

Participants who use a smartphone more were generally more likely to say they read more.

d)

Participants who use a smartphone more were generally less likely to say they read more.

3.

A musician is creating a song using audio samples. Which of the following actions will minimize the risk of a copyright violation when creating sample-based music?  

a)

Using samples found on popular music-streaming sites

b)

Using samples found on peer-to-peer networks

c)

Using samples from nondigital sound sources (vinyl records, tapes, etc.)

d)

Using samples published with a no-rights-reserved Creative Commons license

4.

 The two code segments below are each intended to display the average of the numbers in the list numList. Assume that numList contains more than one value.  

a)

Code segment I displays the correct average, but code segment II does not.

b)

Code segment II displays the correct average, but code segment I does not

c)

Both code segments display the correct average, but code segment I requires more arithmetic operations than code segment II.

d)

Both code segments display the correct average, but code segment II requires more arithmetic operations than code segment I

5.

 Internet protocol version 4 (IPv4) represents each IP address as a 32-bit binary number. Internet protocol version 6 (IPv6) represents each IP address as a 128-bit binary number. Which of the following best describes the result of using 128-bit addresses instead of 32-bit addresses?  

a)

4 times as many addresses are available.

b)

96 times as many addresses are available.

c)

2(4) times as many addresses are available.

d)

2 (96) times as many addresses are available.

6.

 An online retailer uses an algorithm to sort a list of n items by price. The table below shows the approximate number of steps the algorithm takes to sort lists of different sizes.  

a)

The algorithm runs in reasonable time.

b)

The algorithm runs, but not in reasonable time.

c)

The algorithm attempts to solve an undecidable problem.

d)

The algorithm attempts to find an approximate solution whenever it fails to find an exact solution.

7.

  A computer program uses 4 bits to represent nonnegative integers. Which of the following statements describe a possible result when the program uses this number representation? 

I. The operation 4+8 will result in an overflow error. 

II. The operation 7 + 10 will result in an overflow error. 

III. The operation 12 + 3 will result in an overflow error. 

a)

I only

b)

II only

c)

II and III only

d)

I, II, and III

8.

 A NAND gate is a type of logic gate that produces an output of false only when both of its two inputs are true. Otherwise, the gate produces an output of true. Which of the following Boolean expressions correctly models a NAND gate with inputs P and Q ?  

a)

(NOT P) AND (NOT Q)

b)

(NOT P) AND Q

c)

NOT (P AND Q)

d)

NOT (P OR Q)

9.

  A student wants to create an algorithm that can determine, given any program and program input, whether or not the program will go into an infinite loop for that input. 

The problem the student is attempting to solve is considered an undecidable problem. Which of the following is true?   

a)

a

b)

b

c)

c

d)

d

10.

In public key cryptography, the sender uses the recipient’s public key to encrypt a message. Which of the following is needed to decrypt the message?  

a)

The sender’s public key

b)

The sender’s private key

c)

The recipient’s public key

d)

The recipient’s private key

11.

 In a certain science experiment, 75 percent of trials are expected to be successful and 25 percent of trials are expected to be unsuccessful. The program below is intended to simulate the results of repeated trials of the experiment.  

a)

RANDOM (1, 100) = 25

b)

RANDOM (1, 100) ≤ 25

c)

RANDOM (1, 100) = 75

d)

RANDOM (1, 100) ≤ 75

12.

The code segment below is intended to display all multiples of 5 between the values start and end, inclusive. For example, if start has the value 35 and end has the value 50, the code segment should display the values 35, 40, 45, and 50. Assume that start and end are multiples of 5 and that start is less than end.  

a)

end - start + 1

b)

end - start + 6

c)

((end - start) / 5) + 1

d)

5 * (end - start) + 1

13.

The procedure below searches for the value target in list. It returns true if target is found and returns false otherwise.  

a)

I only

b)

II only

c)

I and III

d)

II and III

14.

  A bank customer receives an e-mail from a sender claiming to be a bank employee. The e-mail asks the customer to provide personal information and to call a phone number if he or she has any questions. The customer suspects the e-mail might be a phishing attempt. Which of the following responses is most likely to be a privacy risk for the bank customer?  

a)

Calling the bank at its official phone number to ask whether the request for personal information is

b)

Calling the phone number given in the e-mail and providing the personal information over the phone

c)

Checking that the domain name of the sender’s e-mail address is associated with the bank

d)

Conducting a Web search to see if other people have received similar requests for personal information

15.

Which of the following would be the best use of citizen science?  

a)

An experiment that requires all participants to be working in the same laboratory

b)

An experiment that requires expensive equipment to conduct

c)

An experiment that requires data measurements to be taken in many different locations

d)

An experiment that requires specialized knowledge and training to conduct

16.

  A student is writing a program to model different real-world events using simulations. Which of the following simulations will generate a result that would best be stored using a Boolean variable?  

a)

A simulation of flipping a fair 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

17.

   A smartphone stores the following data for each photo that is taken using the phone. 

• The file name of the photo 

• The date and time the photo was taken 

• The geographic location where the photo was taken 

Assume that all of the photos that have been taken on the phone are accessible. Which of the following can be determined using the photo data described above? 

I. The number of photos that were taken at a particular geographic location 

II. The number of photos that were taken in the last year

III. The name of the person who took the most recent photo   

a)

III only

b)

I and II only

c)

I and III only

d)

I, II, and III

18.

 Which of the following best describes one of the benefits of using an iterative and incremental process of program development?   

a)

It allows programmers to implement algorithmic solutions to otherwise unsolvable problems.

b)

It eliminates the need for programmers to test completed programs.

c)

It enables programmers to create programs that use the lowest-level abstractions available.

d)

It helps programmers identify errors as components are added to a working program

19.

A social media site allows users to send messages to each other. A group of researchers gathered user data for the first 10 years of the site’s existence. Some of the data are summarized in the table below, along with some of the company milestones.   

The researchers noticed that the total number of registered users appears to be increasing at about a constant rate. If this pattern continues, which of the following best approximates the total number of registered users, in millions, in year 12 (two years after the last entry in the table) ?   

a)

30.6

b)

31.2

c)

31.8

d)

32.4

20.

Which of the following hypotheses is most consistent with the data in the table?  

a)

The mobile app release did not have any effect on the average number of daily messages sent per

b)

The mobile app release discouraged new user registration on the site.

c)

The mobile app release led to users being less frequently active on the site

d)

The mobile app release led to users tending to write shorter messages

21.

Consider the two programs below.  

Which of the following best compares the values displayed by programs A and B?  

a)

Program A and program B display identical values.

b)

Program A and program B display the same values in different orders.

c)

Program A and program B display the same number of values, but the values differ.

d)

Program A and program B display a different number of values.

22.

A user reads reviews of a popular artist’s new album and then downloads the album from the Web site of a licensed online music seller. Which of the following is LEAST likely to be a consequence of this action?  

a)

Advertisements for the artist’s other albums will be displayed when the user visits a different Web sites.

b)

Album reviews from other people who live nearby will be displayed to the user

c)

Similar artists will be recommended to the user based on the user’s download selection.

d)

The user will be in violation of the Digital Millennium Copyright Act (DMCA)

23.

 A population researcher is interested in predicting the number of births that will occur in a particular community. She created a computer model that uses data from the past ten years, including number of residents and the number of babies born. The model predicted that there would be 200 births last year, but the actual number of births last year was only 120. Which of the following strategies is LEAST likely to provide a more accurate prediction?  

a)

Gathering data for additional years to try to identify patterns in birth rates

b)

Refining the model used in the computer simulation to more closely reflect the data from the past ten years

c)

Removing as many details from the model as possible so that calculations can be performed quickly

d)

Taking into consideration more information about the community, such as the ages of residents

24.

  An application program interface (API) provides a procedure Max, which returns the greater of its two integer arguments. A programmer would like to find the greatest of three integer values a, b, and c. Which of the following expressions will produce the desired result in every case?  

a)

Max (Max (a, b), c)

b)

Max (a, b) - Max (b, c)

c)

Max (a, b) + Max (b, c) – Max (a, c)

d)

(Max (a, b) + Max (b, c)) / 2

25.

  A student is creating a procedure to determine whether the weather for a particular month was considered very hot. The procedure takes as input a list containing daily high temperatures for a particular month. The procedure is intended to return true if the daily high temperature was at least 90 degrees for a majority of days in the month and return false otherwise  

a)

counter < 0.5 * total

b)

counter > 0.5 * total

c)

total < 0.5 * counter

d)

total > 0.5 * counter

26.

A _____ stores a piece of data, and gives it a specific name.

a)

variable

b)

function

c)

Boolean

d)

comment

27.

A _____ is like a light switch. It can only have two values. Just like a light switch can only be on or off, a _____ can only be True or False

a)

variable

b)

function

c)

Boolean

d)

comment

28.

is a block of code which only runs when it is called. You can pass data, known as parameters, into a ____. A _____ can return data as a result.

a)

variable

b)

function

c)

Boolean

d)

comment