Using Programs with Data FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Use the inventory table.

Row Item Price Qty
1 Notebook 3 10
2 Pen 1 25
3 Notebook 3 4
4 Eraser 2 8
5 Pen 1 12

(a) List the Item values that remain if the program keeps only rows with Price = 1. (b) Compute the total Qty for those remaining rows. Show work. (c) Explain in one sentence what the filter accomplished.

Question 2 of 5

scores ← [70, 85, 90, 60, 85]

PROCEDURE averageOf(list)
{
    s ← 0
    i ← 1
    REPEAT LENGTH(list) TIMES
    {
        s ← s + list[i]
        i ← i + 1
    }
    RETURN s / LENGTH(list)
}

(a) Trace averageOf(scores) and give the returned value with sum shown. (b) A second program displays how many scores are ≥ the average. How many are displayed? (c) Identify one index that is not counted in part (b).

Question 3 of 5

Garden moisture readings:

Bed Moisture
A 12
B 8
C 15
D 8
E 11

(a) Write CSP-style pseudocode that displays every Bed whose Moisture < 10. (b) State the beds displayed. (c) Explain how this filtering extracts information useful to a gardener.

Question 4 of 5

Orders:

OrderID Cost
101 20
102 35
103 20
104 50
105 35
target ← 35
matches ← []
FOR EACH row IN table
{
    IF row.Cost = target
    {
        APPEND(matches, row.OrderID)
    }
}
DISPLAY(matches)

(a) What list is displayed? (b) Modify the idea of the program (in words or pseudocode) to display the average Cost of all orders. (c) Compute that average.

Question 5 of 5

A spreadsheet of bus arrival minutes late: 0, 4, 0, 7, 2.

(a) Describe a program step that counts how many arrivals are late (minutes late > 0). (b) Give that count. (c) Describe a second program step that finds the maximum minutes late and state the result.