81. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?
82. What will be the output of the following Python list comprehension?
[j for i in range(2,8) for j in range(i*2, 50, i)]
[j for i in range(2,8) for j in range(i*2, 50, i)]
83. Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.
84. What will be the output of the following Python code?
s=["pune", "mumbai", "delhi"]
[(w.upper(), len(w)) for w in s]
s=["pune", "mumbai", "delhi"]
[(w.upper(), len(w)) for w in s]
85. What will be the output of the following Python code?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][i] for i in range(len(A))]
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][i] for i in range(len(A))]
86. Suppose list1 is [1, 5, 9], what is sum(list1)?
87. What will be the output of the following Python code?
lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)
lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)
88. What will be the output of the following Python code?
def f(i, values = []):
values.append(i)
return values
f(1)
f(2)
v = f(3)
print(v)
def f(i, values = []):
values.append(i)
return values
f(1)
f(2)
v = f(3)
print(v)
89. What will be the output of the following Python code?
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
if myList[i] > max:
max = myList[i]
indexOfMax = i
>>>print(indexOfMax)
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
if myList[i] > max:
max = myList[i]
indexOfMax = i
>>>print(indexOfMax)
90. Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.