Home »
Python
Python List MCQs with Answers & Explanations
Python List MCQs: This section contains multiple-choice questions and answers on Python List. These MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of Python List.
MCQ Questions and Answers on Python List
Here is the set of important 30 MCQ questions on Python list with answers:
1. What is the list in Python?
- A mutable type of data type which can store anything
- An immutable type of data type which can only store string
- A mutable type of data type which can store only string
- A mutable type of data type which can only store numbers
Answer: A) A mutable type of data type which can store anything
Explanation:
List is python's one of the data types which is mutable and can store anything i.e., numbers, strings, characters, etc.
Discuss this Question
2. Python lists are MUTABLE. What does this statement mean?
- A mutable nature of the python list states that it allows us to store the element at the creation time only
- A mutable nature of the python list states that it allows us to store the data whenever we want after its creation
Answer: B) A mutable nature of the python list states that it allows us to store the data whenever we want after its creation.
Explanation:
A mutable nature of the python list states that it allows us to store the data whenever we want after its creation which means we can modify the data anytime.
Discuss this Question
3. In the python list, different elements are separated by which symbol?
- :
- ,
- ::
- None of the above
Answer: B) ,
Explanation:
In the python list, elements are separated by a comma ( , ) symbol.
Discuss this Question
4. What is the nature of the python list data type?
- In python, lists are of ordered nature
- In python, lists are of unordered nature
Answer: A) In python, lists are of ordered nature.
Explanation:
In python, lists are of ordered nature.
Discuss this Question
5. What do you mean by the ordered nature of the python list?
- The ordered nature of the list indicates that you can only store the data in sequence
- The ordered nature of the list indicates that you can store the data in any sequence
- The ordered nature of the list indicates that the elements which you will put after the creation of the list will be added from the last index
- The ordered nature of the list indicates that the elements which you will put after the creation of the list will be added from the first index
Answer: C) The ordered nature of the list indicates that the elements which you will put after the creation of the list will be added from the last index.
Explanation:
The ordered nature of the list indicates that the elements which you will put after the creation of the list will be added from the last index.
Discuss this Question
6. How do you store list elements?
- List elements are stored using square brackets [] symbol
- List elements are stored using curly brackets {} symbol
- List elements are stored using the parenthesis () symbol
Answer: A) List elements are stored using square brackets [] symbol.
Explanation:
List elements are stored using square brackets [] symbol.
Discuss this Question
7. What will be the result of the above statement?
L1= ["ram", 'hello', 1,2,3, 'hello world']
print (L1)
- ram, hello,1,2,3, hello world
- ['ram', 'hello', 1, 2, 3, 'hello world']
- ERROR
Answer: B) ['ram', 'hello', 1, 2, 3, 'hello world']
Explanation:
The above code prints the list. Here is the output:
['ram', 'hello', 1, 2, 3, 'hello world']
Discuss this Question
8. What element will come at index 5
L1= [99,12,3,33,"ram", "hello",122]
- Ram
- Hello
- 33
- None
Answer: B) Hello
Explanation:
At index 5 hello will come. In the example given above this will be the following indexes: -
99 |
12 |
3 |
33 |
ram |
hello |
122 |
Index 0 |
Index 1 |
Index 2 |
Index 3 |
Index 4 |
Index 5 |
Index 6 |
Discuss this Question
9. How indices in python list are denoted?
L1= [99,12,3,33,"ram", "hello",122]
- L1[index 0] =99;
- L1[index (0)] =99;
- L1 [1] =12;
- L1(1) =12;
Answer: C) L1 [1] =12;
Explanation:
The index of the python list is denoted by: - List name [index]. In the example given above L1 is the list name and 1 is the index so the correct syntax would be L1[1] which will give you 12 as a result as at index 1 we have a 12 as its value.
Discuss this Question
10. Can you make a list inside a list?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, a list can contain another list.
Discuss this Question
11. What will be the output of the following command
L1=["ram","hello",1,2,3,"hello world",[1,2,3,4]] ;
print (L1)?
- "ram","hello",1,2,3,"hello world",1,2,3,4
- "ram","hello",1,2,3,"hello world",[1,2,3,4]
- ["ram","hello",1,2,3,"hello world"],[1,2,3,4]
- Error
Answer: B) "ram","hello",1,2,3,"hello world",[1,2,3,4]
Explanation:
"ram","hello",1,2,3,"hello world",[1,2,3,4] will be the outcome of the above command.
Discuss this Question
12. What is the syntax of slicing the list?
- List (start index, stop index, step)
- List (start index: stop index: step)
- List [start index, stop index, step]
- List [Start index: stop index: step]
Answer: D) List [Start index: stop index: step]
Explanation:
Slicing in python list is used to divide the list according to the start and last index and to do that following syntax is followed: - List [Start index: stop index: step].
Discuss this Question
13. What will be the output of the following statement?
L1= ["ram","hello",1,2,3,"hello world", [1,2,3,4]];
print(L1[:])
- 'ram','hello',1,2,3,'hello world', [1,2,3,4]
- ['ram', 'hello'], [1,2,3,'hello world', [1,2,3,4]]
- ['ram', 'hello'], [1,2,3,'hello world'], [1,2,3,4]
- ERROR
Answer: A) 'ram','hello',1,2,3,'hello world', [1,2,3,4]
Explanation:
'ram','hello',1,2,3,'hello world', [1,2,3,4] will be the output.
Discuss this Question
14. How to access the last element of the list?
- Print L1[last index]
- Print L1 [-1]
- Print L1 [-LAST INDEX]
Answer: B) Print L1 [-1]
Explanation:
To access the last element directly of the list we can use the following syntax: List name[-1].
Discuss this Question
15. What will be the output of the following code?
L1=["apple","hello",1,2,3,"hello world","banana",["Car","Bike",1,2,3,4]] ;
print(L1[-2])
- 3
- Hello
- Banana
- 1
Answer: C) Banana
Explanation:
The -2 index denotes the second last element of the list.
Discuss this Question
16. What do you mean by negative indexing in python?
- Negative indexing in python helps us to traverse the list from the end
- Negative indexing in python helps us to traverse the list from the starting
- There is no such thing as negative indexing in python
Answer: A) Negative indexing in python helps us to traverse the list from the end.
Explanation:
Negative indexing in python helps us to traverse the list from the end.
Discuss this Question
17. What will be the output of the following multidimensional list statement
l1=[["hello",1,2,3], ["Hi"," everyone"," How"," Are"," You"]]
print(l1[1][1])?
- Hello
- 1
- Hi
- Everyone
Answer: D) Everyone
Explanation:
The output would be – Everyone. As the whole list contains 2 other lists it means the original list contains only two indexes 0,1.
Discuss this Question
18. Which python function will get you the size of the python list?
- Size ()
- Len ()
- Lenln ()
- List_len ()
Answer: B) Len ()
Explanation:
Len function will give you the total number of elements present in the list.
Discuss this Question
19. What will be the syntax to use the Len function to get the size of the following list
l1=[["hello",1,2,3], ["Hi"," everyone"," How"," Are"," You"]]?
- Print(len(l1)
- Print (len[l1])
- Print ([ len (l1)])
Answer: A) Print(len(l1)
Explanation:
To get the size of any list we will use the following syntax: - Print(len(l1), where l1 is the name of the list.
Discuss this Question
20. Suppose I have a list L2= [45,56,22,11,34,1,3] and I want to update the value of index 4 to 1000. How will I do that?
- L2= [4] =1000
- L2[3] =1000
- L2[4] =1000
- L2[(4)]=1000
Answer: C) L2[4] =1000
Explanation:
To update the value we will use the following syntax: - L2[4] =1000.
Discuss this Question
21. Which of the following methods will help you to add the element at the end of the list?
- append()
- end()
- add()
- last()
Answer: A) Append()
Explanation:
The append() method in python helps you to add the element at the end of the list.
Discuss this Question
22. What does extends() method do?
- Extend method helps you to insert the element from the starting of the list
- Extend method helps you to insert the element at the end of the list
- Extend methods helps you to insert the element anywhere we want
Answer: B) Extend method helps you to insert the element at the end of the list.
Explanation:
Extend method helps you to insert the element at the end of the list.
Discuss this Question
23. How to use extend() method to insert the element?
- List(extend[element])
- List.extend (elements)
- List.extend ([elements])
Answer: C) List.extend ([elements])
Explanation:
To use extend method we will use the following syntax: - List.extend ([elements])
Discuss this Question
24. What will be the output of the following code?
l1=[45,56,22,["hello","everyone"]]
l1.reverse() print(l1)
- [ ['hello', 'everyone'], 22, 56, 45]
- [['everyone','hello'], 22, 56, 45]
- [22, 56, 45, ['everyone','hello']]
- [22, 56, 45 ['hello', 'everyone']]
Answer: A) Java
Explanation:
[ ['hello', 'everyone'], 22, 56, 45] will be the output.
Discuss this Question
25. To eliminate any element from the list which function will be helpful.
- Delete()
- Remove()
- Undo()
- Del()
Answer: B) Remove()
Explanation:
Remove function will help you to remove the element from the list.
Discuss this Question
26. How do you find the index of any particular element?
- Using list.index()
- Using index().list
- Using only_index().list
Answer: A) Using list.index()
Explanation:
Using list.index() will be used to find the index of any particular element.
Discuss this Question
27. What will be the outcome?
# Suppose you have the following list
l1=["include help","hello","everyone",1,2,[1000,123]]
print(l1.index("hello"))
- 0
- 1
- 2
- 3
Answer: B) 1
Explanation:
The index function will give you the index of the particular element.
Discuss this Question
28. How do you find the total of all the elements of the list?
- total() function
- sum() function
- aggregate() function
- sum_total function
Answer: B) sum() function
Explanation:
The sum() function will help you to find out the sum of all the elements in the list.
Discuss this Question
29. What will be the output of the following code?
L1=[1,276,986,1783]
Print(276 in L1)
- YES
- Error
- True
- False
- 276
Answer: C) True
Explanation:
print (element in list_name) will give you true if the particular element is there in the list else it will return you false.
Discuss this Question
30. What will be the output of the following code?
L1=[10,100,1000,10000]
print(L1*2)
- [20, 200, 2000, 20000, 20, 200, 2000, 20000]
- [10, 100, 1000, 10000, 10, 100, 1000, 10000]
- [20, 200, 2000, 20000]
- Error
Answer: B) [10, 100, 1000, 10000, 10, 100, 1000, 10000]
Explanation:
When you multiply the whole list with some integer then it repeats the elements that number of times so here the output will be [10, 100, 1000, 10000, 10, 100, 1000, 10000].
Discuss this Question