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.

Subtopic: Conditionals and Loops Clear filter

Questions 1–10 of 24
  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 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 3

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 4

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 5

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 6

Multiple choice Conditionals and Loops
A flowchart is a way to visually represent an algorithm. The flowchart below is used by an application to set the Boolean variable available to true under…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Conditionals and Loops
In the following program, assume that the variable n has been initialized with an…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Conditionals and Loops
Assume that the list of numbers nums has more than 10 elements. The program below is intended to compute and display the sum of the first 10 elements of nums.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice Conditionals and Loops
A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then the scores 40, 44, 50, 58, and 60…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice Conditionals and Loops
The procedure BinarySearch(numList, target) correctly implements a binary search algorithm on the list of numbers numList. The procedure returns an index where…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 24
Page 1 of 3