Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

AP CSP MOCK

star
star
star
star
star
Last updated 11 months ago
25 Nsɛmmisa
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

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.

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

A student sends a private file to a teacher via email. Which approach provides the strongest protection against unauthorized access during transfer?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

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:

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

count ← 0

REPEAT UNTIL (count > 5)

{

IF (count MOD 2 = 0)

{

DISPLAY(count)

}

count ← count + 1

}

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

result ← 0

REPEAT 4 TIMES

{

result ← result + 2

IF (result MOD 3 = 0)

{

result ← result + 1

}

}

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

total ← 0

index ← 1

REPEAT UNTIL (index > 5)

{

IF (index MOD 2 = 0)

{

total ← total - index

}

ELSE

{

total ← total + index * 2

}

index ← index + 1

}

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

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)?

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

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])?

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

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)?

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

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])?

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

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])?

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

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])?

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

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)?

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

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"])?

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

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)?

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

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])?

Asemmisa {{asɛmmisaAhyɛnsode}}
23.

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])?

1
Asemmisa {{asɛmmisaAhyɛnsode}}
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?

Asemmisa {{asɛmmisaAhyɛnsode}}
25.

Convert 2391 in base 10 to binary