← AP CSP

Lists and arrays: AP CSP practice

1D and 2D lists, indexes and loops. 7 questions in the style of the AP CSP exam.

Sample questions

What is displayed? In AP pseudocode, DISPLAY shows a value followed by a space, so type every displayed value on one line, separated by single spaces.

nums ← [4, 8, 15]
APPEND(nums, 16)
INSERT(nums, 2, 23)
REMOVE(nums, 4)
FOR EACH item IN nums
{
   DISPLAY(item)
}

Your class uses Python. Write a program that reads a whole number n, then reads n whole numbers (one per line) into a list. Print how many of the numbers are greater than the average of all the numbers.