Log in
Sign up for FREE
arrow_back
Library

AP CSP MOCK

star
star
star
star
star
Last updated 8 months ago
25 questions
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

Question 6
6.

Question 7
7.

Question 8
8.

Question 9
9.

Question 10
10.

Question 11
11.

Question 12
12.

Question 13
13.

Question 14
14.

Question 15
15.

Question 16
16.

Question 17
17.

Question 18
18.

Question 19
19.

Question 20
20.

Question 21
21.

Question 22
22.

Question 23
23.

1
Question 25
25.

Convert 2391 in base 10 to binary

A student writes a program that processes thousands of currency transactions and rounds the results to the nearest cent. Over time, they notice the program's totals are off by several dollars.
A. The program is skipping every tenth transaction.
B. The program is using int instead of float for calculations.
C. The program is rounding down each transaction, losing fractions of a cent.
D. The program is multiplying instead of dividing during conversions.
A student sends a private file to a teacher via email. Which approach provides the strongest protection against unauthorized access during transfer?
a) Sending the file using a fiber-optic high-speed network
b) Sharing the file through a password-protected cloud drive only
c) Encrypting the file using the teacher’s public key
d) Adding a copyright notice to the file
A school’s meal tracking system records data each time a student buys a lunch in the cafeteria. For every transaction, the system stores:
  • The student's name and ID number
  • The date and time of purchase
  • The items purchased and their prices
  • The payment method (e.g., prepaid card, cash)
Which of the following CANNOT be determined from the information stored in the system?
Responses:
A) The total amount of money spent by all students in a given month
B) The most popular food item purchased over the course of a semester
C) The number of students who skipped lunch on a particular school day
D) The average number of items purchased per student in a week
count ← 0
REPEAT UNTIL (count > 5)
{
IF (count MOD 2 = 0)
{
DISPLAY(count)
}
count ← count + 1
}
A) 0 2 4
B) 0 2 4 6
C) 0 1 2 3 4 5
D) 2 4 6
result ← 0
REPEAT 4 TIMES
{
result ← result + 2
IF (result MOD 3 = 0)
{
result ← result + 1
}
}
A) 8
B) 10
C) 11
D) 12
x ← 5
y ← 3
REPEAT UNTIL (x ≤ 0)
{
y ← y + 1
x ← x - 1
IF (y MOD 2 = 0)
{
x ← x - 1
}
}

What is the value of y after the code segment executes?
A) 6
B) 7
C) 8
D) 9
x ← 0
y ← 0
REPEAT 5 TIMES
{
y ← y + 1
IF (y MOD 2 = 1)
{
x ← x + y
}
ELSE
{
x ← x + 2
}
}

What is the value of x after the code segment executes?
A) 9
B) 13
C) 15
D) 19
counter ← 0
sum ← 0
REPEAT UNTIL (counter > 5)
{
IF (counter ≠ 3)
{
sum ← sum + counter
}
counter ← counter + 1
}

What is the value of sum after the code segment executes?
A) 21
B) 15
C) 18
D) 12
aList ← [2, 4, 6, 8, 10]
count ← 0
result ← 0
FOR EACH item IN aList
{
IF (item MOD 4 = 0)
{
count ← count + 1
result ← result + item
}
}

What are the values of count and result after this code segment executes?
A) count = 2, result = 22
B) count = 2, result = 14
C) count = 3, result = 18
D) count = 2, result = 12
x ← 1
REPEAT UNTIL (x > 30)
{
IF (x MOD 3 = 0 AND x MOD 5 = 0)
{
DISPLAY("both")
}
ELSE
{
IF (x MOD 3 = 0)
{
DISPLAY("three")
}
ELSE
{
IF (x MOD 5 = 0)
{
DISPLAY("five")
}
}
}
x ← x + 1
}

How many times will "both" be displayed when this code segment executes?
A) 4
B) 3
C) 2
D) 1
a ← 0
b ← 0
REPEAT 4 TIMES
{
a ← a + 1
REPEAT a TIMES
{
b ← b + 1
}
}

}
What is the value of b after the code segment executes?
A) 4
B) 10
C) 16
D) 20
total ← 0
index ← 1
REPEAT UNTIL (index > 5)
{
IF (index MOD 2 = 0)
{
total ← total - index
}
ELSE
{
total ← total + index * 2
}
index ← index + 1
}
A) 3
B) 7
C) 9
D) 12
PROCEDURE mystery(n)
{
result ← 0
counter ← 0
REPEAT UNTIL (counter > n)
{
IF (counter MOD 3 = 0 OR counter MOD 5 = 0)
{
result ← result + counter
}
counter ← counter + 1
}
RETURN(result)
}

What is returned by the call mystery(10)?
A) 23
B) 33
C) 40
D) 45
PROCEDURE sumEvens(numList)
{
sum ← 0
FOR EACH num IN numList
{
IF (num MOD 2 = 0)
{
sum ← sum + num
}
}
RETURN(sum)
}

What will be returned by the call sumEvens([3, 8, 2, 9, 4])?
A) 6
B) 14
C) 17
D) 26
PROCEDURE mystery(aList, val)
{
count ← 0
FOR EACH item IN aList
{
IF (item > val)
{
count ← count + 1
}
}
RETURN(count)
}

What will be returned by the call mystery([15, 7, 22, 9, 18], 12)?
A) 2
B) 3
C) 4
D) 5
PROCEDURE transform(list1)
{
list2 ← []
FOR EACH item IN list1
{
IF (item < 0)
{
APPEND(list2, item * -1)
}
ELSE
{
APPEND(list2, item * 2)
}
}
RETURN(list2)
}

What will be returned by the call transform([-3, 4, 0, -2, 5])?
A) [-6, 8, 0, -4, 10]
B) [3, 8, 0, 2, 10]
C) [-3, 8, 0, -2, 10]
D) [3, 4, 0, 2, 5]
PROCEDURE modifyList(aList)
{
length ← LENGTH(aList)
i ← 1
REPEAT UNTIL (i > length)
{
IF (aList[i] MOD 3 = 0)
{
REMOVE(aList, i)
length ← length - 1
}
ELSE
{
i ← i + 1
}
}
RETURN(aList)
}

What will be returned by the call modifyList([6, 4, 9, 5, 12, 7])?
A) [4, 5, 7]
B) [6, 4, 5, 7]
C) [4, 5, 12, 7]
D) [6, 4, 9, 5, 7]
PROCEDURE process(aList)
{
result ← []
i ← 1
j ← LENGTH(aList)
REPEAT UNTIL (i > j)
{
APPEND(result, aList[i] + aList[j])
i ← i + 1
j ← j - 1
}
RETURN(result)
}

What will be returned by the call process([3, 1, 4, 2, 7])?
A) [10, 3, 8]
B) [10, 6]
C) [10, 6, 4]
D) [10, 3, 11]
PROCEDURE f1(n)
{
IF (n ≤ 1)
{
RETURN(1)
}
ELSE
{
RETURN(n * f2(n - 1))
}
}

PROCEDURE f2(n)
{
IF (n ≤ 1)
{
RETURN(1)
}
ELSE
{
RETURN(n + f1(n - 1))
}
}

What will be returned by the call f1(3)?
A) 6
B) 9
C) 12
D) 15
PROCEDURE findPattern(wordList)
{
matchList ← []
FOR EACH word IN wordList
{
IF (LENGTH(word) > 3 AND word[1] = "a")
{
APPEND(matchList, word)
}
}
RETURN(matchList)
}

What will be returned by the call findPattern(["apple", "art", "about", "cat", "atom"])?
A) ["apple", "about", "atom"]
B) ["apple", "about"]
C) ["art", "atom"]
D) ["apple", "atom"]
PROCEDURE insertItem(aList, item, position)
{
length ← LENGTH(aList)
IF (position < 1 OR position > length + 1)
{
RETURN(aList)
}
newList ← []
i ← 1
REPEAT UNTIL (i > length + 1)
{
IF (i = position)
{
APPEND(newList, item)
}
IF (i ≤ length)
{
APPEND(newList, aList[i])
}
i ← i + 1
}
RETURN(newList)
}

What will be returned by the call insertItem([10, 20, 30], 25, 2)?
A) [10, 20, 25, 30]
B) [10, 25, 20, 30]
C) [25, 10, 20, 30]
D) [10, 20, 30, 25]
PROCEDURE combine(list1, list2)
{
result ← []
len1 ← LENGTH(list1)
len2 ← LENGTH(list2)
minLen ← minimum(len1, len2)
i ← 1
REPEAT UNTIL (i > minLen)
{
APPEND(result, list1[i])
APPEND(result, list2[i])
i ← i + 1
}
RETURN(result)
}

PROCEDURE minimum(a, b)
{
IF (a ≤ b)
{
RETURN(a)
}
ELSE
{
RETURN(b)
}
}

What will be returned by the call combine([2, 4, 6], [3, 5])?
[5, 9]
[2, 3, 4, 5, 6]
[2, 3, 4, 5]
[2, 3, 4, 5, 6, 0]
PROCEDURE calculateSum(listA, listB)
{
IF (LENGTH(listA) ≠ LENGTH(listB))
{
RETURN(0)
}
sum ← 0
i ← 1
len ← LENGTH(listA)
REPEAT UNTIL (i > len)
{
IF (listA[i] = listB[i])
{
sum ← sum + listA[i]
}
i ← i + 1
}
RETURN(sum)
}

What will be returned by the call calculateSum([5, 3, 7, 2], [8, 3, 7, 5])?
A) 0
B) 7
C) 10
D) 17
Question 24
24.

A file storage application allows users to save their files on cloud servers. A group of researchers gathered user data for the first eight years of the application’s existence. Some of the data are summarized in the following graphs. The line graph on the left shows the number of registered users each year. The line graph on the right shows the total amount of data stored by all users each year. The circle graph shows the distribution of file sizes currently stored by all users.

(note: 1 MB = 1,000 KB)
Which of the following best describes the average amount of data stored per user for the first eight years of the application’s existence?
Across all eight years, the average amount of data stored per user was about 10 GB.
Across all eight years, the average amount of data stored per user was about 100 GB.
The average amount of data stored per user appears to increase by about 100 GB each year
The average amount of data stored per user appears to increase by about 10 GB each year.