wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming in Python, Lists - 9RH

Total questions: 17

Worksheet time: 12mins

Name
Class
Date
1.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
2.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

3.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Jeremy", "Tom"]

a)

"John"

b)

"Harry"

c)

"Jesse"

d)

"Jeremy"

4.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

5.

The list needs one more name added to the end - "Felipe". Which piece of code below would do this?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

6.

To print a list called fruitList we use

a)

print(fruitList)

b)

list(print)

c)

fruitList.print()

d)

fruitList(print)

7.

Which symbols are used to open and close a list?

a)

( ) round brackets

b)

( ) curly brackets

c)

[ ] square brackets

d)

" " speech marks

8.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
9.
Data type for a whole number
a)
String
b)
Integer
c)
Boolean
d)
Float
10.
A location in memory used to store data that can be changed.
a)
Constant
b)
Value
c)
Variable
d)
Iteration
11.

Why is programming important, even if you do not plan to work in computer science? (Multiple answers)

a)

It contributes towards computational thinking and problem solving

b)

We are surrounded by technology, understanding how it works reveals more to us about the world

c)

We rely heavily on technology, we need to understand how to adapt in the future

12.

What would this code do?

a)

Remove the name "Felipe" from the list

b)

Remove the first copy of "John" from the list

c)

Remove the name "Felipe" from the list and print it out to the shell

d)

An error

13.

What would this code show on the screen?

a)

7

b)

6

c)

5

d)

4

e)

An error

14.

Which of these is a list?

a)

["apples", "oranges", "bananas"]

b)

"apples", "oranges", "bananas"

c)

{"apples", "oranges", "bananas"}

d)

("apples", "oranges", "bananas")

15.

Which of these assigns a list to a variable?

a)

fruit = input(["apples", "oranges", "bananas"])

b)

fruit = ["apples", "oranges", "bananas"]

c)

fruit == ["apples", "oranges", "bananas"]

d)

fruit["apples", "oranges", "bananas"]

16.

To insert an item in the first position of a list we use

a)

fruit.append("strawberries, 1")

b)

fruit.insert("strawberries",0)

c)

fruit.insert(1, "strawberries")

d)

fruit.insert(0, "strawberries")

17.

An empty list can be declared as

a)

fruitList = ""

b)

fruitList = ["empty"]

c)

fruitList == []

d)

fruitList = []