Page 359 - Computer Science Class 11 With Functions
P. 359
C. Fill in the blanks.
1. The _________ function is used to add an element at the end of an existing list.
2. While a list is _________, a tuple is ________.
3. The _________ function returns a list comprising elements of a tuple in sorted order.
4. The method mean is included in the module _________.
5. The expression [].pop() will yield _________.
6. [2, 6, 3]*0 will yields _________.
7. [1, 2].extend([4, 5, 6]) yields _______.
8. s = []; s.append((1, 2, 3)); print(s) will print _________.
9. s = []; s.extend((1, 2, 3)); print(s) will print _________.
10. [1, 2, 3, 4] == [1, 2] + [3, 4] will yield _________.
11. [1, 2, 3, 4][2:2] will yield _________.
D. Answer the following questions:
1. What is the difference between mutable and immutable objects? Give an example of an object of each of these types.
Ans. An object that can be modified is called mutable. Example: [1, 2, 3]
An object that cannot be modified is called immutable. Example: (1, 2, 3)
2. Give two examples of mutable types.
Ans. list, and set.
3. Give four examples of immmutable types.
Ans. int, float, tuple, str.
4. What is the index of the first element of a tuple?
Ans. 0
5. What is the difference between a list and a tuple?
Ans: List Tuples
A list is mutable. A tuple is immutable.
Lists are enclosed in brackets[] and their elements and Tuples are enclosed in parethesis() and can not be
size can be changed. updated.
Example: Example:
L = [10,11,12,13] S = ("Orange","education")
or
S = ("orange","education")
6. The function print(x) may be used to display either a list (x) or a tuple (x). Will the output be same or different in the
two case? Justify your answer. Give the output that will be produced on execution of the following code?
print([1, 2, 3])
print((1, 2, 3))
Ans. Elements of a list are separated by commas and enclosed in square parentheses []. Eelements of a tuple are separated by
commas and enclosed in round parentheses ().
[1, 2, 3]
(1, 2, 3)
7. Consider the following assignment statement :
lst = list('Term 1 Exam')
Lists and Tuples 357

