wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

AP CSP Groups & Lists

Total questions: 21

Worksheet time: 10mins

Name
Class
Date
1.

What is the first value of c in the for loop?

a)

saddleBrown

b)

pink

c)

0

d)

1

2.

Look at line 28. What is the value of len(app.colors)

a)

Impossible to tell

b)

5

c)

4

3.

How would we complete the statement in line 23 to set color equal to the last element in app.colors?

a)

color = app.colors.last

b)

color = app.colors[len(app.colors)] - 1

c)

color = app.colors[len(app.colors)]

d)

color = app.colors[len(app.colors) - 1]

4.

What are the possible outcomes of the statement

index % 5

a)

1,2,3,4,5

b)

0,1,2,3,4

c)

0,1,2,3,4,5

d)

infinity

5.

Which of the following expressions evaluate to true when index is a multiple of 5?

a)

index % 5 == 1

b)

index % 5 == 2

c)

index % 5 == 0

d)

index % 5 == 5

6.

Upon 1 mouse click, how many times with the loop on line 57 execute?

a)

4 times - once for each leaf in leaves

b)

8 times - once for each child in leaf

c)

1 time

7.

What does line 54 do ?

a)

adds a head to the app group

b)

adds a head to the app.snake group

c)

adds a head to the app list

d)

adds a head to the app.snake list

8.

How many cabbages will be drawn?

a)

1

b)

10

c)

6

d)

5

e)

7

9.

What will the x coordinate be of the first cabbage drawn?

a)

10

b)

100

c)

1

d)

0

10.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

11.

What will this print to the screen?


print(3*4)

a)

3*4

b)

12

c)

7

d)

error

12.

names = ['anne','ralph', 'jeff', 'lauren', 'sim','peter']

How do you remove 'sim' from the list?

a)

names.(6)

b)

names.delete('sim')

c)

names.remove('sim')

d)

names.append('sim')

13.
What is printed when this program is run:
days = 5 
if days > 6:  
   print(“Month”)

else:  
   print(“Week”)
a)
Month
b)
Week
c)
Day
d)
4
14.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
15.
used to structure code in Python
a)
whitespace
b)
comments
c)
booleans
d)
variables
16.

What is the index number for 'Spain'?

['England','Brazil','Spain','France']

a)

0

b)

1

c)

2

d)

3

17.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

18.

If list=[10,20,30,40,50] then list[2]=35 will result

a)

[35,10,20,30,40,50]

b)

[10,20,30,40,50,35]

c)

[10,20,35,40,50]

d)

[10,35,30,40,50]

19.

If list=[17,23,41,10] then list.append(32) will result

a)

[32,17,23,41,10]

b)

[17,23,41,10,32]

c)

[10,17,23,32,41]

d)

[41,32,23,17,10]

20.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.remove('Tinian')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

21.
a)
b)
c)
d)

1,2,3,4