Font size
WorksheetsPython List and Tuples
Total questions: 15
Worksheet time: 10mins
If list=[17,23,41,10] then list.append(32) will result
[32,17,23,41,10]
[17,23,41,10,32]
[10,17,23,32,41]
[41,32,23,17,10]
Which of the following python function can be used to add more than one element within an existing list ?
append( )
append_more( )
extend( )
more( )
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:])
[20, 30, 40, 50]
[10, 20, 30, 40]
[30, 40, 50, 60, 70, 80]
[30, 40, 50]
[10, 20, 30, 40]
[40, 50, 60, 70, 80]
None of these
In Python, list is mutable
False
True
___________method adds a single item to the end of the list.
extend( )
append( )
insert( )
list1=[10, 20, 30, 40] and list2=[15, 25, 35, 45] What is the value of list1 when the statement,
list1+=list2
is executed?
[10, 20, 30, 40]
[25, 45, 65, 85]
[10, 15, 20, 25, 30, 35, 40, 45]
[10, 20, 30, 40, 15, 25, 35, 45]
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?
‘b222’
'c333’
['a111', 'b222', 'd444’]
["a111", "b222", "c333", "d444"]
Consider a tuple, fruits= (‘apple’, ‘orange’, ‘watermelon’, ‘grapes’, ‘banana’).
What is the output for the statement print(fruits[-2])?
‘banana’
‘grapes’
‘watermelon’
‘orange’
Which of the following is TRUE about tuples?
Tuples represent elements of the same data type.
The length of a tuple can be changed.
New elements are inserted to tuples using the append() method.
Elements of a tuple cannot be modified.
Consider the list L= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34].What will be output of the statement L [3:6]?
[2, 3, 5]
[0, 1, 1]
[1, 2, 3]
[2, 3, 5, 8]
Choose the correct about Tuples
Collection of items which are ordered
tuples cannot be changed
tuples uses square brackets
values of tuples can be accessed by indexing
Choose the correct syntax of Tuple
tuple=[200,50]
tuple=(200,50)
tuple={200,50}
Which of the following is FALSE about lists?
A list is an ordered collection.
A list is a collection of heterogeneous elements.
A list consists of elements of the same data type only.
A list consists of zero or more elements.
Guess the output:
li = [2, 3, 5]
li.append("Rahul")
print(li)
SyntaxError
[2, 3, 5, 'Rahul']
['Rahul', 2, 3, 5]
