---
title: "AP Computer Science A Unit 1: Practice Questions with Answers | FiveStudy"
description: "5 free AP Computer Science A practice questions on Unit 1, with answers and explanations. Try them, then keep practicing on FiveStudy."
url: https://fivestudy.com/ap-computer-science-a/unit-1
---

[AP Computer Science A](https://fivestudy.com/ap-computer-science-a) · Unit practice

# AP Computer Science A Unit 1: practice questions

5 exam-style questions with answers and explanations. Answer them on FiveStudy to keep a streak and see your AP® score estimate.

## Question 1

A student writes the following steps to find the average of two test scores. Step 1: Set total to the first score. Step 2: Add the second score to total. Step 3: Divide total by 2 and store the result in average. Step 4: Display average.

Which of the following best describes the value displayed by Step 4?

- A. The average of the two test scores
- B. The sum of the two test scores
- C. Half of the first test score
- D. The larger of the two test scores

**Answer:** The average of the two test scores

Steps 1 and 2 build the sum of the two scores in total, and Step 3 divides that sum by 2, which is the average. The sum itself is displayed only if Step 3 is removed, and no step compares the two scores.

## Question 2

The steps below are intended to display the total cost of an order after a 5 dollar shipping charge is added, but they do not work as intended. Step 1: Set total to the price of the item. Step 2: Display total. Step 3: Add 5 to total.

Which of the following changes makes the steps work as intended?

- A. Change Step 3 so that it subtracts 5 from total.
- B. Move the step that displays total so that it is the last step.
- C. Change Step 1 so that total starts at 5 instead of the item price.
- D. Perform Step 3 a second time before the steps end.

**Answer:** Move the step that displays total so that it is the last step.

The display step runs before the shipping charge is added, so the charge is missing from the displayed value; displaying total last fixes the order. Subtracting 5, starting total at 5, and adding 5 twice all produce a value other than the price plus 5.

## Question 3

A recipe app must display the name of every ingredient in a recipe. Which of the following descriptions of the algorithm expresses this task most clearly?

- A. Display the name of the first ingredient in the recipe.
- B. If the recipe has an ingredient, display the recipe's title.
- C. For each ingredient in the recipe, display the ingredient's name.
- D. Display the number of ingredients that the recipe contains.

**Answer:** For each ingredient in the recipe, display the ingredient's name.

Displaying every name requires a step that repeats once per ingredient, which is what the phrase "for each ingredient" expresses. The other descriptions handle only the first ingredient, display the title, or display a count.

## Question 4

Two students describe the same recipe-doubling algorithm differently. Student X begins by listing each ingredient amount and doubling it. Student Y begins from the serving count and derives every doubled quantity from it.

Both descriptions accept the same recipe as input and produce the same doubled ingredient list. What does this demonstrate about algorithms?

- A. Equivalent algorithms can present different sequences of steps while sharing the same input-to-output behavior
- B. Only the description whose steps appear in the same order as the source lines qualifies as an algorithm
- C. At least one description must contain an error whenever the stated steps differ in any way
- D. Matching variable declaration positions across descriptions is required for algorithmic equivalence

**Answer:** Equivalent algorithms can present different sequences of steps while sharing the same input-to-output behavior

Identical input/output contracts define equivalence regardless of internal step wording or starting point.

## Question 5

Two step lists each begin with count set to 4. List I Step 1: Add 2 to count. Step 2: Multiply count by 3. List II Step 1: Multiply count by 3. Step 2: Add 2 to count.

Which of the following statements about the final value of count is true?

- A. Both lists end with 18, because the same two operations are performed.
- B. Both lists end with 14, because addition is performed before multiplication.
- C. List I ends with 14 and List II ends with 18.
- D. List I ends with 18 and List II ends with 14.

**Answer:** List I ends with 18 and List II ends with 14.

List I computes (4 + 2) * 3 = 18, while List II computes 4 * 3 + 2 = 14, so the order of the steps changes the result. Performing the same two operations in a different order does not have to produce the same value.

[More AP Computer Science A practice](https://fivestudy.com/ap-computer-science-a)

## Other units

- [Unit 2](https://fivestudy.com/ap-computer-science-a/unit-2)
- [Unit 3](https://fivestudy.com/ap-computer-science-a/unit-3)
- [Unit 4](https://fivestudy.com/ap-computer-science-a/unit-4)
