31. What will be the output of the following Python code?
def change(var, lst):
var = 1
lst[0] = 44
k = 3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)
def change(var, lst):
var = 1
lst[0] = 44
k = 3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)
32. Which of the following commands will create a list?
33. What is the list comprehension equivalent for?
{x : x is a whole number less than 20, x is even} (including zero)
{x : x is a whole number less than 20, x is even} (including zero)
34. What will be the output of the following Python code?
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
v = values[0][0]
for lst in values:
for element in lst:
if v > element:
v = element
print(v)
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
v = values[0][0]
for lst in values:
for element in lst:
if v > element:
v = element
print(v)
35. What will be the output of the following Python code?
l=["good", "oh!", "excellent!", "#450"]
[n for n in l if n.isalpha() or n.isdigit()]
l=["good", "oh!", "excellent!", "#450"]
[n for n in l if n.isalpha() or n.isdigit()]
36. Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?
37. What will be the output of the following Python code?
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
myList[i - 1] = myList[i]
for i in range(0, 6):
print(myList[i], end = " ")
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
myList[i - 1] = myList[i]
for i in range(0, 6):
print(myList[i], end = " ")
38. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
39. How many elements are in m?
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
40. Write the list comprehension to pick out only negative integers from a given list 'l'.
Read More Section(Lists in Python)
Each Section contains maximum 100 MCQs question on Lists in Python. To get more questions visit other sections.