0% found this document useful (0 votes)
49 views4 pages

AP Computer Science Principles Session2 MCQ

The document contains a series of multiple-choice questions related to AP Computer Science Principles, focusing on program documentation, testing procedures, and algorithm efficiency. It includes scenarios for evaluating code functionality, simulating election results, and improving program performance. The questions are designed to assess understanding of programming concepts and best practices.

Uploaded by

sharul.shah2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

AP Computer Science Principles Session2 MCQ

The document contains a series of multiple-choice questions related to AP Computer Science Principles, focusing on program documentation, testing procedures, and algorithm efficiency. It includes scenarios for evaluating code functionality, simulating election results, and improving program performance. The questions are designed to assess understanding of programming concepts and best practices.

Uploaded by

sharul.shah2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2024 AP DAILY: PRACTICE SESSIONS

AP Computer Science Principles


Session 2 – MCQ

1. Which of the following is a true statement about program documentation?

A. Program documentation should not be changed after it is first written.


B. Program documentation is only needed for programs in development; it is not needed after a
program is completed.
C. Program documentation is useful when programmers collaborate but not when a programmer
works individually on a project.
D. Program documentation is useful during initial program development and also when modifications
are made to existing programs.

2. The procedure below is intended to display the index in a list of unique names (nameList) where
a particular name (targetName) is found. If targetName is not found in nameList, the code should
display 0.
PROCEDURE FindName (nameList, targetName)
{
index ← 0
FOR EACH name IN nameList
{
index ← index + 1
IF (name = targetName)
{
foundIndex ← index
}
ELSE
{
foundIndex ← 0
}
}
DISPLAY (foundIndex)
}

Source: AP Practice Exam; Taken from: APClassroom 1


Which of the following procedure calls can be used to demonstrate that the procedure does NOT work
as intended?
A. FindName ([“Andrea”, “Ben”], “Ben”)
B. FindName ([“Andrea”, “Ben”], “Diane”)
C. FindName ([“Andrea”, “Ben”, “Chris”], “Ben”)
D. FindName ([“Andrea”, “Ben”, “Chris”], “Ben”)

3. A programmer wrote the program below. The program uses a list of numbers called numList. The
program is intended to display the sum of the numbers in the list.

In order to test the program, the programmer initializes


numList to [0, 1, 4, 5].
The program displays 10, and the programmer concludes that the program works as intended. Which
of the following is true?

A. The conclusion is correct; the program works as intended.


B. The conclusion is incorrect; the program does not display the correct value for the test case [0, 1,
4, 5].
C. The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the
program is correct.
D. The conclusion is incorrect; using the test case [0, 1, 4, 5] only confirms that the program works
for lists in increasing order.

Source: AP Practice Exam; Taken from: APClassroom 2


4. In a certain district, 20 percent of the voters are expected to vote for Candidate A in an election. The
computer program below is intended to simulate the result of the election with n voters, and display
the number of votes received by Candidate A.
Line 1: sum ← 0
Line 2: REPEAT n TIMES
Line 3: {
Line 4: IF (<MISSING CONDITION>)
Line 5: {
Line 6: sum ← sum + 1
Line 7: }
Line 8: }
Line 9: DISPLAY (sum)

Which of the following can be used to replace <MISSING CONDITION> in line 4 so that the
program works as intended?
Select two answers.

A. RANDOM(1, 5) = 1
B. RANDOM(1, 5) < 2
C. RANDOM(1, 10) = 2
D. RANDOM(1, 10) < 2

5. A new bank plans to make customer convenience a priority by minimizing the amount of time a
customer waits in line. The bank is considering two options: a single line where the customer at the
front waits for the next available teller, or separate lines for each teller. The bank decides to use a
computer simulation of these two options to determine the average wait time for customers.
Which of the following is NOT true about the bank’s plan?

A. The bank can incorporate other factors, such as the number of tellers, in the simulation.
B. The bank can use the simulation to investigate these two options without causing inconvenience
for customers.
C. The bank may consider new alternatives based on the simulation results.
D. The simulation will not produce usable results because actual customer data are not available.

Source: AP Practice Exam; Taken from: APClassroom 3


6. A programmer wrote the code segment below to display the average of all the elements in a list called
numbers. There is always at least one number in the list.
Line 1: count ← 0
Line 2: sum ← 0
Line 3: FOR EACH value IN numbers
Line 4: {
Line 5: count ← count + 1
Line 6: sum ← sum + value
Line 7: average ← sum / count
Line 8: }
Line 9: DISPLAY (average)

The programmer wants to reduce the number of operations that are performed when the program is
run. Which change will result in a correct program with a reduced number of operations performed?

A. Interchanging line 1 and line 2


B. Interchanging line 5 and line 6
C. Interchanging line 6 and line 7
D. Interchanging line 7 and line 8

7. Which of the following statements is true?

A. Every problem can be solved with an algorithm for all possible inputs, in a reasonable amount of
time, using a modern computer.
B. Every problem can be solved with an algorithm for all possible inputs, but some will take more
than 100 years, even with the fastest possible computer.
C. Every problem can be solved with an algorithm for all possible inputs, but some of these
algorithms have not been discovered yet.
D. There exist problems that no algorithm will ever be able to solve for all possible inputs.

8. A certain computer game is played between a human player and a computer-controlled player. Every
time the computer-controlled player has a turn, the game runs slowly because the computer evaluates
all potential moves and selects the best one. Which of the following best describes the possibility of
improving the running speed of the game?

A. The game’s running speed can only be improved if the game is played between two human players
instead of with the computer-controlled player.
B. The game’s running speed might be improved by using a process that finds approximate solutions
every time the computer-controlled player has a turn.
C. The game’s running speed cannot be improved because computers can only be programmed to
find the best possible solution.
D. The game’s running speed cannot be improved because the game is an example of an algorithm
that does not run in a reasonable time.

Source: AP Practice Exam; Taken from: APClassroom 4

You might also like