Verityprep
Question Bank · Unit 4

AP® Computer Science Principles Algorithms and Programming Practice Questions

Work through AP Computer Science Principles practice questions on Algorithms and Programming, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Questions 1–10 of 100
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Conditionals and Loops

Consider the following program.

Figure

Which of the following expressions represents the value stored in the variable x as a result of executing the program?

Pick an answer, then check it. The solution opens in a window.

Question 2

Multiple choice Variables and Assignments

Of the following software abstractions, which is considered the highest level of abstraction?

Pick an answer, then check it. The solution opens in a window.

Question 3

Multiple choice Conditionals and Loops
An algorithm is intended to display the following output. red red blue red red blue red red blue…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice Algorithms

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right.

Figure

The following programs are each intended to move the robot to the gray square. Program II uses the procedure GoalReached, which returns true if the robot is in the gray square and returns false otherwise.

Figure

Which of the following statements best describes the correctness of the programs?

Pick an answer, then check it. The solution opens in a window.

Question 5

Multiple choice Algorithms
Which of the following actions are generally helpful in program development? I. Consulting potential users of the program to identify their concerns…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice Conditionals and Loops
Ticket prices for a science museum are shown in the following table. Type of Ticket General Admission Cost (in dollars) Guided Tour Cost (in dollars) Regular…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Algorithms
The following algorithm is intended to take a positive integer as input and display its individual digits in order from right to left. For example, if the input…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Conditionals and Loops

Consider the two programs below.

Figure

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

Pick an answer, then check it. The solution opens in a window.

Question 9

Multiple choice Conditionals and Loops
A student wrote the following program to remove all occurrences of the strings "the" and "a" from the list wordList. Line 1: index ← LENGTH (wordList) Line 2:…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice Algorithms

The grid below contains a robot represented as a triangle, initially facing right. The robot can move into a white or gray square but cannot move into a black region.

Figure

The code segment below uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise.

REPEAT UNTIL (GoalReached ())
{
    <MISSING CODE>
}

Which of the following replacements for <MISSING CODE> can be used to move the robot to the gray square?

Pick an answer, then check it. The solution opens in a window.
Question 1 of 100
Page 1 of 10