wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Long Test Part 3 - LIsts_IT1107

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following correctly creates a list in Python?

a)

list = (1, 2, 3)

b)

list = {1, 2, 3}

c)

list = [1, 2, 3]

d)

list = <1, 2, 3>

2.

What is the index of the first element in a Python list?

a)

-1

b)

0

c)

1

d)

Depends on the list

3.

Which operation adds an item to the end of a list?

a)

list.add(x)

b)

list.push(x)

c)

list.append(x)

d)

list.insert(x)

4.

What does the len() function return when used on a list?

a)

Total memory used

b)

Last element

c)

Number of elements

d)

Size of list in bytes

5.

Which of the following removes and returns the last element of a list?

a)

remove()

b)

pop()

c)

delete()

d)

discard()

6.

What happens if you try to access an index that does not exist?

a)

Returns None

b)

Returns an empty string

c)

Returns False

d)

Raises an IndexError

7.

Which list method inserts an item at a given position?

a)

insert()

b)

append()

c)

extend()

d)

place()

8.

Which statement about Python lists is TRUE?

a)

Lists are immutable

b)

Lists cannot be nested

c)

Lists require all elements to be integers

d)

Lists can hold elements of different data types

9.

What does list.extend([x, y]) do?

a)

Adds [x, y] as a single element

b)

Replaces existing elements

c)

Adds x and y individually to the list

d)

Removes x and y

10.

Which of the following demonstrates the correct way to add something to the following list variable?

temperatures = [44, 36, 72]

a)

append(temperatures, 42)

b)

temperatures = temperatures + 42

c)

temperatures.append(42)

d)

temperatures.append[1]

11.

What is the output of the following?

a)

1

b)

-1

c)

4

d)

3

12.

What will this code print?

a)

[10, 20]

b)

[20, 30]

c)

[20, 30, 40]

d)

[30, 40]

13.

What does this code print?

a)

[1, 2]

b)

[3, 4]

c)

[1, 2, 3, 4]

d)

10

14.

What will this code print?

a)

[5, 2, 9, 1]

b)

[9, 5, 2, 1]

c)

Error

d)

[1, 2, 5, 9]

15.

What is the result of this code?

a)

[1, 2, 3]

b)

[1, 10, 3]

c)

[10, 2, 3]

d)

Error: lists are immutable

16.

What is the output of the following code?

a)

9

b)

12

c)

6

d)

3

17.

What does this code print?

a)

["pen", "paper"]

b)

["pen", "paper", "book"]

c)

["pen", "paper", "book", "bag"]

d)

["bag"]

18.

What does this code print?

a)

[1, 2, 10, 3]

b)

[10, 1, 2, 3]

c)

[1, 10, 2, 3]

d)

[1, 2, 3, 10]

19.

What will this code output?

a)

4

b)

5

c)

3

d)

2

20.

What is the output?

a)

x-y-z-

b)

x, y, z-

c)
  • -x y z-

d)

x y z -