Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python-lists

Total questions: 10

Worksheet time: 4mins

Name
Class
Date
1.

What is a list in python?

a)

A collection of variables

b)

A collection of items assigned to a single variable

c)

A statement that cant be changed

d)

A Christmas list

2.

Which of these codes is correct for creating a list of numbers?

a)

num = ('10','29','37','109')

b)

num = ['10','29','37','109']

c)

num == ('10','29','37','109')

d)

num = ['10 29 37 109']

3.

What is the index number for 'Spain'?

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

a)

0

b)

1

c)

2

d)

3

4.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

5.

What brackets are used to create a list?

a)

()

b)

[]

6.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

7.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

8.

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

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

9.

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]

10.
Following set of commands are executed in shell, what will be the output?
>>>str="hello"
>>>str[:2]
>>>
a)
he
b)
lo
c)
olleh
d)
hello