# Python List MCQs

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.

## List of Python List MCQs

1. What is the list in Python?

1. A mutable type of data type which can store anything
2. An immutable type of data type which can only store string
3. A mutable type of data type which can store only string
4. 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.

2. Python lists are MUTABLE. What does this statement mean?

1. A mutable nature of the python list states that it allows us to store the element at the creation time only
2. 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.

3. In the python list, different elements are separated by which symbol?

1. :
2. ,
3. ::
4. None of the above

Explanation:

In the python list, elements are separated by a comma ( , ) symbol.

4. What is the nature of the python list data type?

1. In python, lists are of ordered nature
2. In python, lists are of unordered nature

Answer: A) In python, lists are of ordered nature.

Explanation:

In python, lists are of ordered nature.

5. What do you mean by the ordered nature of the python list?

1. The ordered nature of the list indicates that you can only store the data in sequence
2. The ordered nature of the list indicates that you can store the data in any sequence
3. 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
4. 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.

6. How do you store list elements?

1. List elements are stored using square brackets [] symbol
2. List elements are stored using curly brackets {} symbol
3. 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.

7. What will be the result of the above statement?

```L1= ["ram", 'hello', 1,2,3, 'hello world']
print (L1)```
1. ram, hello,1,2,3, hello world
2. 'ram','hello',1,2,3,'hello world'
3. ERROR

Explanation:

The result will show you the error because in the list the string type of data is always stored in double quotation marks "", and in the statement given above hello and hello world both string types are written in single quotation marks.

8. What element will come at index 5

```L1= [99,12,3,33,"ram", "hello",122]
```
1. Ram
2. Hello
3. 33
4. None

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

9. How indices in python list are denoted?

```L1= [99,12,3,33,"ram", "hello",122]
```
1. L1[index 0] =99;
2. L1[index (0)] =99;
3. L1  =12;
4. 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 which will give you 12 as a result as at index 1 we have a 12 as its value.

10. Can you make a list inside a list?

1. Yes
2. No

Explanation:

Yes, a list can contain another list.

11. What will be the output of the following command

```L1=["ram","hello",1,2,3,"hello world",[1,2,3,4]] ;
print (L1)?
```
1. "ram","hello",1,2,3,"hello world",1,2,3,4
2. "ram","hello",1,2,3,"hello world",[1,2,3,4]
3. ["ram","hello",1,2,3,"hello world"],[1,2,3,4]
4. Error

Explanation:

"ram","hello",1,2,3,"hello world",[1,2,3,4] will be the outcome of the above command.

12. What is the syntax of slicing the list?

1. List (start index, stop index, step)
2. List (start index: stop index: step)
3. List [start index, stop index, step]
4. 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].

13. What will be the output of the following statement?

```L1= ["ram","hello",1,2,3,"hello world", [1,2,3,4]];
print(L1[:])
```
1. 'ram','hello',1,2,3,'hello world', [1,2,3,4]
2. ['ram', 'hello'], [1,2,3,'hello world', [1,2,3,4]]
3. ['ram', 'hello'], [1,2,3,'hello world'], [1,2,3,4]
4. ERROR

Explanation:

'ram','hello',1,2,3,'hello world', [1,2,3,4] will be the output.

14. How to access the last element of the list?

1. Print L1[last index]
2. Print L1 [-1]
3. Print L1 [-LAST INDEX]

Explanation:

To access the last element directly of the list we can use the following syntax: List name[-1].

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])
```
1. 3
2. Hello
3. Banana
4. 1

Explanation:

The -2 index denotes the second last element of the list. 16. What do you mean by negative indexing in python?

1. Negative indexing in python helps us to traverse the list from the end
2. Negative indexing in python helps us to traverse the list from the starting
3. 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.

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. Hello
2. 1
3. Hi
4. 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.

18. Which python function will get you the size of the python list?

1. Size ()
2. Len ()
3. Lenln ()
4. List_len ()

Explanation:

Len function will give you the total number of elements present in the list.

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"]]?
```
1. Print(len(l1)
2. Print (len[l1])
3. 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.

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?

1. L2=  =1000
2. L2 =1000
3. L2 =1000
4. L2[(4)]=1000

Explanation:

To update the value we will use the following syntax: - L2 =1000.

21. Which of the following methods will help you to add the element at the end of the list?

1. append()
2. end()
4. last()

Explanation:

The append() method in python helps you to add the element at the end of the list.

22. What does extends() method do?

1. Extend method helps you to insert the element from the starting of the list
2. Extend method helps you to insert the element at the end of the list
3. 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.

23. How to use extend() method to insert the element?

1. List(extend[element])
2. List.extend (elements)
3. List.extend ([elements])

Explanation:

To use extend method we will use the following syntax: - List.extend ([elements])

24. What will be the output of the following code?

```l1=[45,56,22,["hello","everyone"]]
l1.reverse() print(l1)```
1. [ ['hello', 'everyone'], 22, 56, 45]
2. [['everyone','hello'], 22, 56, 45]
3. [22, 56, 45, ['everyone','hello']]
4. [22, 56, 45 ['hello', 'everyone']]

Explanation:

[ ['hello', 'everyone'], 22, 56, 45] will be the output.

25. To eliminate any element from the list which function will be helpful.

1. Delete()
2. Remove()
3. Undo()
4. Del()

Explanation:

Remove function will help you to remove the element from the list.

26. How do you find the index of any particular element?

1. Using list.index()
2. Using index().list
3. Using only_index().list

Explanation:

Using list.index() will be used to find the index of any particular element.

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"))```
1. 0
2. 1
3. 2
4. 3

Explanation:

The index function will give you the index of the particular element.

28. How do you find the total of all the elements of the list?

1. total() function
2. sum() function
3. aggregate() function
4. sum_total function

Explanation:

The sum() function will help you to find out the sum of all the elements in the list.

29. What will be the output of the following code?

```L1=[1,276,986,1783]
Print(276 in L1)```
1. YES
2. Error
3. True
4. False
5. 276

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.

30. What will be the output of the following code?

```L1=[10,100,1000,10000]
print(L1*2)```
1. [20, 200, 2000, 20000, 20, 200, 2000, 20000]
2. [10, 100, 1000, 10000, 10, 100, 1000, 10000]
3. [20, 200, 2000, 20000]
4. 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].