wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python List and Tuples

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

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]

2.

Which of the following python function can be used to add more than one element within an existing list ?

a)

append( )

b)

append_more( )

c)

extend( )

d)

more( )

3.
What output will this code produce?
a)
red
b)
['blue', 'green', 'red']
c)
['red', 'green', 'blue']
d)
error
4.

What is the output of the following list operation

aList = [10, 20, 30, 40, 50, 60, 70, 80]

print(aList[2:5])

print(aList[:4])

print(aList[3:])

a)

[20, 30, 40, 50]

[10, 20, 30, 40]

[30, 40, 50, 60, 70, 80]

b)

[30, 40, 50]

[10, 20, 30, 40]

[40, 50, 60, 70, 80]

c)

None of these

5.

In Python, list is mutable

a)

False

b)

True

6.

___________method adds a single item to the end of the list.

a)

extend( )

b)

append( )

c)

insert( )

7.

list1=[10, 20, 30, 40] and list2=[15, 25, 35, 45] What is the value of list1 when the statement,

list1+=list2

is executed?

a)

[10, 20, 30, 40]

b)

[25, 45, 65, 85]

c)

[10, 15, 20, 25, 30, 35, 40, 45]

d)

[10, 20, 30, 40, 15, 25, 35, 45]

8.

lista=["a111", "b222", "c333", "d444"]

The statement lista.pop(2) is executed. Which of the following is the correct representation of lista after the statement, lista.pop(2) is executed?

a)

‘b222’

b)

'c333’

c)

['a111', 'b222', 'd444’]

d)

["a111", "b222", "c333", "d444"]

9.

Consider a tuple, fruits= (‘apple’, ‘orange’, ‘watermelon’, ‘grapes’, ‘banana’).

What is the output for the statement print(fruits[-2])?

a)

‘banana’

b)

‘grapes’

c)

‘watermelon’

d)

‘orange’

10.

Which of the following is TRUE about tuples?

a)

Tuples represent elements of the same data type.

b)

The length of a tuple can be changed.

c)

New elements are inserted to tuples using the append() method.

d)

Elements of a tuple cannot be modified.

11.

Consider the list L= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34].What will be output of the statement L [3:6]?

a)

[2, 3, 5]

b)

[0, 1, 1]

c)

[1, 2, 3]

d)

[2, 3, 5, 8]

12.

Choose the correct about Tuples

a)

Collection of items which are ordered

b)

tuples cannot be changed

c)

tuples uses square brackets

d)

values of tuples can be accessed by indexing

13.

Choose the correct syntax of Tuple

a)

tuple=[200,50]

b)

tuple=(200,50)

c)

tuple={200,50}

14.

Which of the following is FALSE about lists?

a)

A list is an ordered collection.

b)

A list is a collection of heterogeneous elements.

c)

A list consists of elements of the same data type only.

d)

A list consists of zero or more elements.

15.

Guess the output:


li = [2, 3, 5]

li.append("Rahul")

print(li)

a)

SyntaxError

b)

[2, 3, 5, 'Rahul']

c)

['Rahul', 2, 3, 5]