0% found this document useful (0 votes)
62 views7 pages

Chapter-4 (1) MCQ

This document contains multiple choice, true/false, and fill in the blank questions about lists in Python. It covers list basics like the types of values lists can contain, how to create empty and non-empty lists, list operations like indexing, slicing, concatenation and multiplication. It also discusses list methods for adding, removing, searching and sorting elements in lists.

Uploaded by

eyaansiddiqui703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views7 pages

Chapter-4 (1) MCQ

This document contains multiple choice, true/false, and fill in the blank questions about lists in Python. It covers list basics like the types of values lists can contain, how to create empty and non-empty lists, list operations like indexing, slicing, concatenation and multiplication. It also discusses list methods for adding, removing, searching and sorting elements in lists.

Uploaded by

eyaansiddiqui703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CHAPTER-4 LIST

Multiple Choice Question


1. List can contain values of these types:
(a) integers
(b) floats
(c) lists
(d) tuples
(e) all of these

2. Which of the following will create an empty list?


(a) L = [ ]
(b) L = list(0)
(c) L = list()
(d) L = List(empty)

3. Which of the following will return the last element of a list L with 5 elements
?
(a) L[5]
(b) L[4]
(c) L[-1]
(d) L[6]

4. If L = [1, 2] then L*2 will yield


(a) [1, 2] * 2
(b) [1, 2, 2]
(c) [1, 1, 2, 2]
(d) [1, 2, 1, 2]

5. If L1 = [1, 3, 5] and L2 = [2, 4, 6] then L1 + L2 will yield


(a) [1, 2, 3, 4, 5, 6]
(b) [1, 3, 5, 2, 4, 6]
(c) [3, 7, 11]
(d) [1, 3, 5, [2, 4, 6]]

6. Given a list L = [10, 20, 30, 40, 50, 60, 70], what would L[1:4] return?
(a) [10, 20, 30, 40]
(b) [20, 30, 40, 50]
(c) [20, 30, 40]
(d) [30, 40, 50]

7. Given a list L = [10, 20, 30, 40, 50, 60, 70], what would L[2: -2] return?
(a) [10, 20, 30, 40]
(b) [20, 30, 40, 50]
(c) [20, 30, 40]
(d) [30, 40, 50]

8. Given a list L = [10, 20, 30, 40, 50, 60, 70], what would L[-4-:1] return?
(a) [20, 30, 40]
(b) [30, 40, 50]
(c) [40, 50, 60]
(d) [50, 60, 70]

9. Given a list L = [10, 20, 30, 40, 50, 60, 70], what would L[-3: 99] return?
(a) [20, 30, 40]
(b) [30, 40, 50]
(c) [40, 50, 60]
(d) [50, 60, 70]
10. To find the last element of list namely ‘smiles’ in Python, _____ will be
used.
(a) smiles[0]
(b) smiles[-1]
(c) smiles[lpos]
(d) smiles[:-1]

11. Out of the following what is correct syntax to copy one list into another ?
(a) listA = listB[]
(b) listA = listB[:]
(c) listA = listB[ ]()
(d) listA = list(listB)

12. What is printed by the Python code ?


print (list (range(3)))
(a) [0. 1, 2, 3]
(b) [1, 2, 3]
(c) [0, 1, 2]
(d) 0, 1, 2

13. Which of the following commands will create a list ?


(a) list1 = list()
(b) list1 = [ ]
(c) list1 = list([1, 2, 3])
(d) all of these

14. What is the output when we execute list("hello") ?


(a) ('h', 'e', ‘l’, ‘1’, 'o')
(b) ['hello'].
(c) [‘llo’]
(d) ['olleh'].

15. What gets printed?


names = ["Hasan", "Balwant”, ‘Sean’, ‘Dia']
print(names[-1][-1])
(a) H
(b) n
(c) Hasan
(d) Dia
(e) a

16. What is the output of the following


l = [None] * 10
print(len(l))
(a) 10
(b) 0
(c) Syntax Error
(d) None

17. Which of the following is a standard Python library function and not an
exclusively list function?
(a) append()
(b) remove()
(c) pop()
(d) len()

18. Which of the following can add only one value to a list?
(a) add()
(b) append()
(c) extend()
(d) none of these

19. Which of the following can add a list of elements to a list ?


(a) add()
(b) append()
(c) extend()
(d) none of these

20. Which of the following will always return a list?


(a) max()
(b) min()
(c) sort()
(d) sorted()

21. Which of the following can delete an element from a list if the index of the
element is given?
(a) pop()
(b) remove()
(c) del
(d) all of these

22. Which of the following can delete an element from a list, if its value is
given?
(a) pop()
(b) remove()
(c) del
(d) all of these
23. Which of the following searches for an element in a list and returns its
index?
(a) search()
(b) find())
(c) index()
(d) lsearch()

24. Which of the following can copy a list another list?


(a) list()
(b) new()
(c) copy()
(d) = operato
True / False
1. The list () and copy () are the similar functions.
2. The pop () and remove() are similar functions.
3. A = [] and A = list () will produce the same result.
4. Lists once created cannot be changed.
5. To sort a list, sort () and sorted (), both can be used.
6. The extend () adds a single element to a list.
7. The append() can add an element in the middle of a list.
8. The insert() can add an element in the middle of a list.
9. The del statement can only delete list slices and not single elements from a
list
10. The del statement can work similar to the pop() function.
Ans
1. False
2. False
3. True
4. False
5. True
6. False
7. False
8. True
9. False
10. True
Fill In the Blanks
1. Lists are _____ data types and thus their values can be changed.
2. To create an empty list, function _____ can be used.
3. The _____ operator adds one list to the end of another list.
4. The _____ operator replicates a list.
5. To check if an element is in list, _____ operator is used.
6. To delete a list slice from a list _____ is used.
7. The _____ function is used to insert element at a designated position in a list.
8. The _____ function is used to delete element to remove an element from
designated index in a list.
9. The _____ function can append a list of elements to a list.
10. The _____ function sorts a list and makes changes in the list.
11. The _____ function sorts a list and returns another list.
Ans
1. mutable
2. list()
3. +
4. *
5. in
6. del statement
7. insert
8. pop()
9. extend
10. sort
11. sorted()

You might also like