Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Python List MCQs with Answers & Explanations

includehelp.com/python/python-list-mcqs.aspx

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.

Discuss this Question

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.

Discuss this Question

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


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

Answer: B) ,

Explanation:

1/11
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?


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.

Discuss this Question

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.

Discuss this Question

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.

2/11
Discuss this Question

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

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]

1. Ram
2. Hello
3. 33
4. 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]

1. L1[index 0] =99;

3/11
2. L1[index (0)] =99;
3. L1 [1] =12;
4. 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?

1. Yes
2. 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)?

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

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?

4/11
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].

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[:])

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

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?

1. Print L1[last index]


2. Print L1 [-1]
3. 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

5/11
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

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?

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.

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])?

1. Hello
2. 1
3. Hi

6/11
4. 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?
1. Size ()
2. Len ()
3. Lenln ()
4. 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"]]?

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

7/11
1. L2= [4] =1000
2. L2[3] =1000
3. L2[4] =1000
4. 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?

1. append()
2. end()
3. add()
4. 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?

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.

Discuss this Question

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

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

8/11
3. 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)

1. [ ['hello', 'everyone'], 22, 56, 45]


2. [['everyone','hello'], 22, 56, 45]
3. [22, 56, 45, ['everyone','hello']]
4. [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.

1. Delete()
2. Remove()
3. Undo()
4. 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?


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

9/11
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"))

1. 0
2. 1
3. 2
4. 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?

1. total() function
2. sum() function
3. aggregate() function
4. 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)

1. YES

10/11
2. Error
3. True
4. False
5. 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)

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].

11/11

You might also like