wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

List, Tuples, & Slicing Review 2024

Total questions: 40

Worksheet time: 42mins

Name
Class
Date
1.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

2.

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

a)

numList = 1, 2, 3, 4, 5, 6

b)

numList = (1, 2, 3, 4, 5, 6)

c)

numList = [1, 2, 3, 4, 5, 6]

d)

numList = [1 2 3 4 5 6]

3.

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

a)

nameList = Juan, Aaron, Rosario, John, Irvin, Selina

b)

nameList = ("Juan", "Aaron", "Rosario", "John", "Irvin", "Selina")

c)

nameList = ["Juan", "Aaron", "Rosario", "John", "Irvin", "Selina"]

d)

nameList = [Juan, Aaron, Rosario, John, Irvin, Selina]

4.

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

["Juan", "Aaron", "Rosario", "John", "Irvin", "Selina"]

a)

"John"

b)

"Juan"

c)

"Rosario"

d)

"Irvin"

5.

What would this code show on the screen?

a)

7

b)

6

c)

5

d)

4

e)

An error

6.
people = ["John", "Rob", "Bob"]
print (people[-1])
What would this result be?
a)
John
b)
Rob
c)
Bob
d)
Error
7.

What would this code print to the console?

a)

Nothing will print to the console

b)

An error will print to the console

c)

"Woo hoo, you scored!"

d)

"Raheem"

8.

Zoe is learning about lists and tuples in Python. She knows that one of them is mutable and the other is immutable. James and Ava are having a debate about this. Which of the following statements is correct?

a)

James says that both lists and tuples are mutable.

b)

Ava says that lists are mutable whereas tuples are immutable.

c)

James says that both lists and tuples are immutable.

d)

Ava says that lists are immutable whereas tuples are mutable.

9.

What is the output of the program above

a)

<class 'tuple'>

b)

<class 'None'>

c)

<class 'list'>

d)

<class 'int'>

10.

Result of the program above is

a)

('1', '2', '3', '4', '5')

b)

(1, 2, 3, 4, 5)

c)

12345

d)

"12345"

11.

If list1=[17,23,41,10]

then list1.append(32) will result in:

a)

[32,17,23,41,10]

b)

[17,23,41,10,32]

c)

[10,17,23,32,41]

d)

[41,32,23,17,10]

12.

If list2=[5,9,12,20,15]

then list2.sort() will result in:

a)

[15, 5, 9, 12, 20]

b)

[5, 9, 12, 15, 20]

c)

[15, 20, 12, 9, 5]

13.

word = "amazing"

For the given string if we run word[2:5] what does it mean?

a)

It will extract alphabets from index 2 to index 4

b)

It will extract alphabets from index 2 to index 5

c)

It will extract alphabets from position 2 to position 4

d)

It will extract alphabets from position 2 to position 5

14.

If a tuple and list contain identical values which datatype is larger in size when the computer creates it and allocate memory for it?

my_list=[5,9,12,20,15]

my_tuple=(5,9,12,20,15)

a)

Tuple

b)

List

c)

both will have the same memory space allocation since they are identical.

15.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

16.

alpha = 'abcdef'

alpha[0:3]

a)

'abc'

b)

'abcd'

c)

'abcde'

d)

none

17.

What is the purpose of index 0 in a list?

a)

To access the first item

b)

To access the second item

c)

To access the last item

d)

To access the item at index 1

18.

alpha = 'abcdef'

alpha[0:4]

a)

'ab'

b)

'abc'

c)

'abcd'

19.

Which brackets are used for Lists?

a)

( )

b)

[ ]

c)

{ }

d)

None of the above

20.

alpha = 'abcdef'

alpha[2:4]

a)

'cd'

b)

b'cd'

c)

'abcd'

d)

'cde'

21.

When we create a program to extract each alphabet from a given string, what is it known as?

a)

Transpose

b)

Traverse

c)

Translate

d)

Terminate

22.

alpha = 'abcdef'

alpha[2:]

a)

'cdf'

b)

'ef'

c)

'def'

d)

'cdef'

23.

Function used to add element in to List?

a)

Add( )

b)

append( )

c)

update( )

24.

alpha = 'abcdef'

alpha[0:6:2]

a)

'ace'

b)

'abce'

c)

'acde'

d)

'ce'

25.

What is the output of program below?


bicycles = ['trek', 'cannondale', 'redline', 'specialized']

print(bicycles[-1])

a)

trek

b)

cannondale

c)

redline

d)

specialized

26.

What is the output of the program below?


cars = ['audi', 'bmw', 'mercedes', 'tesla']

print(cars[-2])

a)

audi

b)

bmw

c)

mercedes

d)

tesla

27.

For example:

numbers = [ [1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]

print(numbers[2][1]) refers to .......................

a)

1

b)

2

c)

6

28.

Which of the following statements is true about a 2D list in Python?

a)

It is a single list with two elements.

b)

It is a list of dictionaries.

c)

It is a list of lists.

29.

Which would be the correct code to access number 10

a)

list_2d[3][4]

b)

list_2d= [2,3]

c)

list_2d[2][3]

d)

list_2d(0,0)

30.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
31.

In which order are the numbers?

a)

[row][column]

b)

[column][row]

32.

What name would be printed with the code print(names[1][1])

a)

Jim

b)

Sarah

c)

Bob

d)

John

33.

cars=["mini", "VW", "BMW"]

x = len(cars)

print(x)

What will the above code print?

a)

mini,VW,BMW

b)

2

c)

9

d)

3

34.

A two-dimensional array Array_2d consists of data: [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]. What is the output of print(Array_2d[1][1])?

a)

1

b)

2

c)

5

d)

6

35.

What would be returned with the code print([2][1]

a)

Index out of range

b)

Bob

c)

John

d)

Jim

36.

What will be the output for the program above?

a)

[15, 7, 95]

b)

15

c)

35

d)

7

37.

What will be the output for the program above?

a)

[15, 7, 95]

b)

15

c)

95

d)

7

e)

35

38.

What will be the output for the code above?

a)

[4,35,[15,7,95]]

b)

[4,35,[15,7,95],[21,47]]

c)

[4, 35, 15, 7, 95, 21, 47]

d)

[4, 35, [15, 7, 95], 21, 47]

39.

What will be the output for the program above?

a)

[[78,86,100,97],100,60,70,95]

b)

[100, 60, 70, 95, [78, 86, 100, 97]]

c)

[100, 60, 70, 95, 78, 86, 100, 97]

40.

What does this program print?

a)

[48, 56, 64, 65, [60, 61, 62]]

b)

[48, 56, 60, 61, 62, 64, 65]

c)

[48, 56, 64, 65, 60, 61, 67]

d)

[48, 56, 64, 65, 60, 61, 62]