Engineering Python : UNIT IV : Lists, Tuples, Dictionaries : Anna University Multiple Choice Questions & Answers
Multiple Choice Questions
Q.
1 Which of the following is true regarding lists in Python ?
a.
Lists are immutable
b.
Size of the lists must be specified before its initialization
c.
Elements of lists are stored in contagious memory location
d.
size(mylist) command is used to find the size of lists
Ans : c. Elements of lists are stored in contagious memory
location
Q.
2 In lists values are enclosed in ------
a.
square brackets
b.
curly brackets
c.
parenthesis
d.
none of the above
Ans : a. square brackets
Q.
3 What is the output of the following code ?
>>>
fruits = [“Mango", "banana", "grapes", "apple”]
>>>fruits
[2]
a.
banana
b.
grapes
c.
apple
d.
none of these
Ans : b. grapes
Q.
4 Which of the following will create a list ?
a. mylist = list()
b.
mylist = [ ]
c.
mylist = list([10,20,30])
d.
all of the above
Ans : d. all of the above
Q.
5 What will be the output if we execute ?
>>>list("India")
a.
['I','n','d','1','a']
b.
['India']
c.
['ndia']
d.
Error
Ans : a. ['I','n','d','1','a']
Q.
6 What is the output of the following
>>>
mylist = ['l','n','d', 'I', 'a']
>>>
len(mylist)
a.
4
b.
5
c.
6
d.
Error
Ans : b. 5
Q.
7 Suppose mylist is [10, 13, 22, 30, 75], What is mylist[-1] ?
a.
Error
b.
None
c.
75
d.
10
Ans : c. 75
Q.
8 Suppose mylist is [10, 13, 22, 30, 75), What is mylist[:-1] ?
a.
Error
b.
[10,13,22,30]
c.
75
d.
10
Ans : b. [10,13,22,30]
Q.
9 Suppose mylist is [10, 13, 22, 30, 75], What is mylist[::-1] ?
a.
[75,30,22,13,10]
a.
None
c.
75
d.
10
Ans
: a. [75,30,22,13,10]
Q.
10 What will be the output of the following ?
>>>
mylist = [2,4,6,8,10,12]
>>>
mylist.remove(2)
>>>
print(sum(mylist))
a.
26
b.
40
c.
32
d.
Error
Ans : b. 40
Q.
11 In tuples values are enclosed in --------
a.
square brackets
b.
curly brackets
c.
parenthesis
d.
none of the above
Ans : c. parenthesis
Q.
12 What is the output of the following ?
T
= tuple("Python")
print(T)
a.
(python)
b.
(“Python")
c.
('P', 'y', 'X', 'h', 'o', 'n')
d.
None of the above
Ans : c. ('P', 'y', 'X', 'h', 'o', 'n')
Q.
13 T = list(tuple("Python"))
print(T)
a.
('P', 'y', 't', 'H', 'o', 'n')
b.
['P', 'y', 'ť', H', 'o', 'n']
c.
None of the above
d.
Error
Ans : b. ['P', 'y', 'ť', H', 'o', 'n']
Q.
14 Which of the following is not a function of tuple ?
a.
update()
b.
min()
c.
max()
d.
count()
Ans : a. update()
Q.
15 Which of the following are the features of tuple ?
a.
tuple is immutable
b.
tuple is a sequence data type.
c.
in tuple, elements are enclosed in Parenthesis.
d.
all of the above
Ans
: d. all of the above
Q.
16 What is the length of the given tuple ? >>> t1=(1,2,(3,4,5))
a.
1
b.
2
c.
3
d.
4
Ans : c. 3
Q.
17 Dictionaries in python are -------
a.
mutable data type
b.
non-Mutable data type
c.
mapping data type
d.
both a and c
Ans : d. both a and c
Q.
18 Keys in dictionary must be ---------
a.
unique
b.
mutable
c.
integer
d.
strings
Ans : a. unique
Q.19
Which statement is used to create an empty dictionary ?
a.
d = {}
b.
d=( )
c.
d = dict{ }
d.
d = [ ]
Ans : a. d = {}
Q.
20 Only values (without keys) can be printed in dictionary?
a.
True
b.
False
Ans : a. True
Problem Solving and Python Programming: UNIT IV: Lists, Tuples, Dictionaries : Tag: Engineering Python : Lists, Tuples, Dictionaries | Problem Solving and Python Programming - Multiple Choice Questions
Problem Solving and Python Programming
GE3151 1st Semester | 2021 Regulation | 1st Semester Common to all Dept 2021 Regulation