Mcq's List
Mcq's List
Mcq's List
A. list1=[] C. list1=[2,8,7]
B. list1=[]*3 D. None
2. 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 (list1) command is used to find the size of lists.
3. What will be the output of below Python code?
list1=[8,0,9,5]
print(list1[::-1])
A. [5,9,0,8] B. [8,0,9] C. [8,0,9,5] D. [0,9,5]
4. Which of the following will give output as [23,2,9,75] ?If list1=[6,23,3,2,0,9,8,75]
A. print(list1[1:7:2]) B. print(list1[0:7:2])
C. print(list1[1:8:2]) D. print(list1[0:8:2])
5. The marks of a student on 6 subjects are stored in a list, list1=[80,66,94,87,99,95].
How can the student’s average mark be calculated?
A. print(avg(list1)) C. print(sum(list1)/sizeof(list1))
B. print(sum(list1)/len(list1)) D. print(total(list1)/len(list1))
6. What will be the output of following Python code?
list1=["Python","Java","c","C","C++"]
print(min(list1))
A. c B. C++ C. C D. min function cannot be used on string elements
7. The elements of a list are arranged in descending order. Which of the following two will give same outputs?
i. print(list_name.sort()) ii. print(max(list_name))
iii. print(list_name.reverse()) iv. print(list_name[-1])
A. i, ii B. i, iii C. ii, iii D. iii, iv
8. What will be the result after the execution of above Python code?
list1=[3,2,5,7,3,6]
list1.pop(3)
print(list1)
A. [3,2,5,3,6] C. [2,5,7,6]
B. [2,5,7,3,6] D. [3,2,5,7,3,6]
a) [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]] c) [[[2, 3, 9]], [[2, 3, 9]]]
b) [[2, 3, 9], [2, 3, 9], [2, 3, 9]] d) None of these
29. What is the output of the following program?
data = [x for x in range(5)]
temp = [x for x in range(7) if x in data and x%2==0]
print(temp)
a) [0, 2, 4, 6] c) [0, 1, 2, 3, 4, 5]
b) [0, 2, 4] d) Runtime error
30. What is the output of the following program?
temp = ['Geeks', 'for', 'Geeks']
arr = [i[0].upper() for i in temp]
print(arr)