CH 10,11,12 and 13 Practice Questions
CH 10,11,12 and 13 Practice Questions
PRACTICE QUESTIONS
1. Define List.
2. Differentiate between List and String.
3. List out various types of operators/operations supported by List in python.
4. Differentiate between L.append() and L.extend() with an example.
5. Differentiate between L.insert() and L.extend() with an example.
6. Differentiate between L.pop() and L.remove() with an example.
7. Differentiate between del and L.clear() with an example.
8. Differentiate between L.sort() and sorted() with an example.
9. Differentiate between L.reverse() and L[::-1].
TOPIC - LISTS
STATE TRUE OR FALSE
1. List immutable data type.
2. List hold key and values.
3. Lists once created cannot be changed.
4. The pop() and remove() are similar functions.
5. The append() can add an element in the middle of the list.
6. Del statement deletes sub list from a list.
7. Sort() and sorted() both are similar function.
8. l1=[5,7,9,4,12] 5 not in l1
9. List can be extend
10. Mutable means only we can insert elements
11. Index of last element in list is n-1, where n is total number of elements.
12. We can concatenate only two list at one time.
13. L.pop() method will return deleted element immediately
14. L.insert() method insert a new element at the beginning of the list only.
15. If index is not found in insert() I.e. L.insert(102,89) then it will add 89 at the
end of the list.
16. L.reverse() will accept the parameters to reverse the elements of the list.
17. L.sort(reverse=1) will reverse the list in descending order
18. L.pop() used to delete the element based on the element of the list.
19. L.clear() used to clear the elements of the list but memory will exists after clear.
20. L.append() append more than one element at the end of the list.
21. L=[10,20,30]
L.extend([90,100])
print(L)
output of the above code is:
[10,20,30,[90,100]]
22. After sorting using L.sort() method, the index number of the list element will
change.
23. L.remove() used to delete the element of the list based on its value, if the
specified value is not there it will return Error.
ASSERTION & REASONING
1. A: list is mutable data Type
R: We can insert and delete as many elements fromlist
2. A: Elements can be added or removed from a list
R: List is an immutable datatype.
3. A: List can be changed after creation
R: List is mutable datatype.
4. A: Following code will result into output :True
a=[10,20]
b=a[:]
print( a is b)
R:"is" is used for checking whether or not both the
operands is using same memory location
5. A: list() is used to convert string in to list element
R: string will be passed into list() it will be converted into
list elements
6. A: reverse() is used to reverse the list elements.
R: it can reverse immutable data type elements also
7. A: pop() can delete elements from the last index of list
R: this function can remove elements from the last index
only.
8. A: len() displays the list length
R: it is applicable for both mutable and immutable data type.
9. A: Usha wants to sort the list having name of students of
her class in descending order using sorted()function
R: sorted() function will sort the list in ascending order
10. A: Raju is working on a list of numbers. He wants to print the list values using
traversing method. He insists that list can be traversed in forward direction
and backward direction i.e. from beginning to last and last to beginning.
R: List can be traversed from first element to last element only.
11. A: Anu wants to delete the elements from the list using pop() function.
R: Her friend Pari suggested her to use del () function to delete more than one
element from the list.
12. A: Students in the Lab practical were asked to store
the elements in a List data type in which we can
perform all the operations like addition, deletion,
deletion, traversal.
R: List is mutable data type
OBJECTIVE TYPE QUESTIONS(MCQ)
1. Which point can be considered as difference between string and list?
(a) Length (b) Indexing and Slicing
(c) Mutability (d) Accessing individual elements
2. What is the output when we execute list(“hello”)?
(a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] (b) [‘hello’] (c) [‘llo’] (d) [‘olleh’].
3. Given a List L=[7,18,9,6,1], what will be the output of
L[-2::-1]?
(a) [6, 9, 18, 7] (b) [6,1] (c) [6,9,18] (d) [6]
4. If a List L=['Hello','World!'] Identify the correct output of the following Python
command: >>> print(*L)
(a) Hello World! (b) Hello,World!
(c)'Hello','World!' (d) 'Hello','World!'
5. Consider the list aList=[ "SIPO", [1,3,5,7]]. What would the following code print?
(a) S, 3 (b) S, 1 (c) I, 3 (d) I, 1
6. Suppose list1 is [1, 3, 2], What is list1 * 2 ?
a) [2, 6, 4] (b) [1, 3, 2, 1, 3]
(c) [1, 3, 2, 1, 3, 2] (d) [1, 3, 2, 3, 2, 1]
7. Suppose list1 = [0.5 * x for x in range(0,4)], list1 is
a) [0, 1, 2, 3] b) [0, 1, 2, 3, 4]
c) [0.0, 0.5, 1.0, 1.5] d) [0.0, 0.5, 1.0, 1.5, 2.0]
8. >>>L1=[6,4,2,9,7]
>>>print(L1[3:]= "100"
(a) [6,4,2,9,7,100] (b) [6,4,2,100]
(c) [6,4,2,1,0,0] (d) [6,4,2, ‘1’,’0’,’0’]
9. Which statement is not correct
a)The statement x = x + 10 is a valid statement
b)List slice is a list itself.
c)Lists are immutable while strings are mutable.
d)Lists and strings in pythons support two way indexing
10. Which one is the correct output for the following code?
a=[1,2,3,4]
for x in range(0,len(a)):
b=[sum(a[0:x+1])
print (b)
(a) 10 (b) [1,3,5,7] (c) 4 (d) [1,3,6,10]
11. What will be the output for the following python code:
L=[10,20,30,40,50]
L=L+5
print(L)
(a) [10,20,30,40,50,5] (b) [15,25,35,45,55]
(c) [5,10,20,30,40,50] (d) Error
12. Select the correct output of the code:
L1, L2 = [10, 23, 36, 45, 78], [ ]
for i in range(len(L1)) :
L2.insert(i, L1.pop( ) )
print( L1, L2, sep=’@’)
(a) [78, 45, 36, 23, 10] @ [ ]
(b) [10, 23, 36, 45, 78] @ [78, 45, 36, 23, 10]
(c) [10, 23, 36, 45, 78] @ [10, 23, 36, 45, 78]
(d) [ ] @ [78, 45, 36, 23, 10]
13. The append() method adds an element at
(a) First (b) Last (c) Specified index (d) At any location
14. The return type of x in the below code is
txt = "I could eat bananas all day"
x = txt.partition("bananas")
(a) string (b) List (c) Tuple (d) Dictionary
15. S1: Operator + concatenates one list to the end of another
list.
S2: Operator * is to multiply the elements inside the list.
Which option is correct?
(a) S1 is correct, S2 is incorrect
(b) S1 is incorrect, S2 is incorrect
(c) S1 is incorrect, S2 is incorrect
(d) S1 is incorrect, S2 is correct
16. Which of the following statement is true for extend() list method?
(a) Adds element at last
(b) Adds multiple elements at last
(c) Adds element at specified index
(d) Adds elements at random index
17. What is the output of the following code?
a=[1,2,3,4,5]
for i in range(1,5): (a) 5 5 1 2 3 (b) 5 1 2 3 4
a[i-1]=a[i]
for i in range(0,5): (c) 2 3 4 5 1 (d) 2 3 4 5 5
print(a[i],end=" ")
THEORY QUESTIONS
1. Define Tuple.
2. Differentiate between List and Tuple.
3. List out various types of operators/operations supported by Tuples in python.
4. List out various types of built in function and methods supported by tuple.
5. Can we sort the tuple elements using T.sort()? If not, which built in function or
method will help you to sort the elements.
1. Define Dictionary.
2. List out various ways of creating Dictionary in python.
3. List out various types of operators/operations supported by Dictionary in python.
4. List out various types of built in function or method supported by Dictionary.
5. Differentiate between : (i) D.keys() and D.items()
6. Differentiate between : (i) D.keys() and D.get()
7. Differentiate between: (i) D.pop() and D.popitem()
8. Differentiate between: (i) D.update() and D.copy()
9. Differentiate between: (i) D.values() and D.setdefault()
*****************************************************************************