wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP Algorithms

Total questions: 23

Worksheet time: 12mins

Name
Class
Date
1.

What will the following algorithm display?
\leftarrow   13
\leftarrow   17
\leftarrow   a + 1
\leftarrow   a/7
DISPLAY(c)
DISPLAY(a)
DISPLAY(b)

a)

2, 14, 17

b)

13, 17, 5

c)

2, 12, 2

d)

14, 17, 2

2.

What will the following algorithm display?

a ← 13

a ← 17

a ← a+1

DISPLAY(a)

a)

13

b)

17

c)

18

d)

19

3.

What will the following algorithm display?

a ← 11

a ← a + 35

a ← a + 6

a ← a MOD 2

a ← a x b

DISPLAY (a)

a)

0

b)

42

c)

84

d)

126

4.

Extra Credit: Before deciding on a Hedgehog, Sega originally planned to make Sonic a...

a)

rabbit

b)

goose

c)

cat

d)

dinosaur

5.

What will the following display?

a ← "Milk"

a ← "Cookies Soda"

a ← "Chips"

b ← a + "put them in a bag so they stay crisp"

a)

Milk

b)

Milk Cookies Soda

c)

Put them in a bag so they crisp

d)

Milk Cookies Soda Chips put them in a bag so they stay crisp

6.

What is the value displayed after the program is run?
\leftarrow  8
\leftarrow  3
\leftarrow  2
\leftarrow  b * c
\leftarrow  c+4
display "a"
display (c)

a)

a  8

b)

a  6

c)

8  6

d)

16  4

7.

 What is the value displayed after the program is run?
\leftarrow  8
\leftarrow  3
\leftarrow  2
\leftarrow  b*c
\leftarrow   c+4
DISPLAY("a")
DISPLAY("c")

a)

a  8

b)

a  c

c)

8  6

d)

16  4

8.

What will the following algorithm display?
\leftarrow  26 MOD 2

a)

26

b)

13

c)

0

d)

1

9.

What will the following algorithm display?
\leftarrow  5 MOD 2
DISPLAY (a)

a)

26

b)

13

c)

0

d)

1

10.

What will the following algorithm display?
a \leftarrow  8 MOD 26
display(a)

a)

26

b)

13

c)

8

d)

1

11.

Extra Credit: Before deciding on the name "Sonic", the original name of the character was

a)

Speedy

b)

Mach

c)

Mr. Needlemouse

d)

Gus

12.

What will the following algorithm display?

a ← 13 MOD 26

display(a)

a)

26

b)

13

c)

8

d)

0

13.

What will the following algorithm display?

a ←26 MOD 13

display(a)

a)

26

b)

13

c)

8

d)

0

14.

What will the following algorithm display?

a ←26 MOD 3

b ←7 MOD a

display (b)

a)

26

b)

13

c)

0

d)

1

15.

What will the following algorithm display?

a ←2 MOD 3

b ←7 MOD a

display (b)

a)

26

b)

13

c)

0

d)

1

16.

What will the following segment display?

a ← 13

b ← 5

temp ← a

a ← b

b ← temp

display (a)

display (b)

a)

13 5

b)

5 13

c)

a b

d)

13 13

17.

What is the percentage that this algorithm displays true?

Display(RANDOM(1, 10) = 6)

a)

9

b)

10

c)

60

d)

100

18.

What is the percentage that this algorithm displays true?

DISPLAY(random(5,9) = 6)

a)

10

b)

20

c)

60

d)

100

19.

Extra Credit: Sonic's footwear was inspired by...

a)

Michael Jordan

b)

Michael Jackson

c)

Mickey Mouse

d)

Wreck-it-Ralph

20.

What is the percentage that this algorithm displays true?

DISPLAY (RANDOM(5,9) = 4)

a)

0

b)

20

c)

60

d)

100

21.

What is the percentage that this algorithm displays true?
DISPLAY(RANDOM(5,9) \le   9)

a)

0

b)

20

c)

60

d)

100

22.

What is the percentage that this algorithm displays true?

DISPLAY(RANDOM(5,9)>9)

a)

0

b)

20

c)

60

d)

100

23.

What is the percentage that this algorithm displays true?

DISPLAY(RANDOM(1, 10) ≤6

a)

9

b)

10

c)

60

d)

100