List Manipulation Exam Questions Class 11 Computer Science

Exam Questions Class 11

Please see Chapter 7 List Manipulation Exam Questions Class 11 Computer Science below. These important questions with solutions have been prepared based on the latest examination guidelines and syllabus issued by CBSE, NCERT, and KVS. We have provided Class 11 Computer Science Questions and answers for all chapters in your NCERT Book for Class 11 Computer Science. These solved problems for List Manipulation in Class 11 Computer Science will help you to score more marks in upcoming examinations.

Exam Questions Chapter 7 List Manipulation Class 11 Computer Science

Short Answer Type Questions

Question: Distinguish between string and list.
Answer: Strings are immutable, which means the values provided to them will not change in the program. While lists are mutable which means the values of list can be changed at any point of time in program.
4. What is the output of below questions?
l2 = [75, 43, 40, 36, 28, 82]
(i) l2.sort ( )
(ii) l2.sort (reverse = True)
Answer: (i) [28, 36, 40, 43, 75, 82]
(ii) [82, 75, 43, 40, 36, 28]

Question: What is nested list ? Explain with an example.
Answer: Nested lists are list objects where the elements in the lists can be lists themselves.
For example, list1=[45,43,12, ‘Math’, ‘Eng’, [75,34,‘A’],5]
Here, list1 contains 7 elements, while inner list contains
3 elements. list1 is considered [75, 34, ‘A’] as one element.

Question: Find the errors.
L1=[2, 4, 5, 9]
L2=L1 * 3
L3=L1 +3
L4=L1. pop (5)
Answer: Error 1 L3 = L1 + 3 because + operator cannot add list with other type as number or string.
Error 2 L1.pop (5) parentheses puts index value instead of element. In the given list, maximum index value is 3 and 5 is out of index range.

Question: What will be the output of the following Python code?
a=[13,6,77]
a.append([87])
a.extend([45,67])
print(a)
Answer: [13,6,77, [87], 45, 67]

Question: list1 = [45, 77, 87, ‘Next’, ‘Try’, 33, 43]
Observe the given list and find the answer of questions that follows.
(i) list1[−2] (ii) list1[2]
Answer: (i) 33 (ii) 87

Question:Predict the output.
L2 = [4, 5, 3, 1]
L3 = [3, 4, 11, 2]
(i) print (L2 + L3)
(ii) print (L2. count (0))
(iii) print (L3 [4])
(iv) L3. remove(11)
print (L3)
Answer: (i) [4, 5, 3, 1, 3, 4, 11, 2] (ii) 0
(iii) IndexError (iv) [3, 4, 2]

Question: What will be the output of the following Python code?
a=[18,23,69,[73]]
b=list(a)
a[3][0]=110
a[1]=34
print(b)
Answer: [18, 23, 69, [110]]

Question: Predict the output.
L1 = [3, 4, 5, 9, 11, 2, 27]
print (L1. index (3))
print (max (L1))
print (len (L1))
Answer: Output
0
27
7

Question: Define the replicating lists with an example.
Answer: In Python, you can repeat the elements of the list using (*)
operator. This operator is used to replicate the list.
For example,
>>>l1 = [4, 5, 7, 1]
>>>l2 = l1 * 2
>>>l2
[4, 5, 7, 1, 4, 5, 7, 1]

Question: Find the output.
L = [3, 4, 53, 4, 0, 2, 4, 7, 29]
(i) L [2 : 5] (ii) L [: 7]
(iii) L [4 :] (iv) [: : −1]
Answer: (i) [53, 4, 0] (ii) [3, 4, 53, 4, 0, 2, 4]
(iii) [0, 2, 4, 7, 29] (iv) [29, 7, 4, 2, 0, 4, 53, 4, 3]
10. Find the output of the given code.
list2 = [‘A’,‘R’,‘I’,‘H’,‘A’,‘N’,‘T’]
for i in range (len (list2)):
print (list2 [i])
Answer: A
R
I
H
A
N
T

Question: Consider the following list and answer the below questions.
l1 = [89, 45, “Taj”, “Qutub”, 93, 42, “Minar”, “Delhi”, “Agra”]
(i) l1 [5 :] (ii) “Qutab” not in l1
(iii) l1 [−3] (iv) l1 [9]
(v) l1[2 : 5] (vi) l1[–2 : 5]
Answer: (i) [42, ‘Minar’, ‘Delhi’, ‘Agra’]
(ii) False
(iii) ‘Minar’
(iv) It gives IndexError because there is index value 0 to 8.
(v) [‘Taj’, ‘Qutub’, 93]
(vi) [ ] 

Question: Consider the following list myList. What will be the elements of myList after the following two operations:
myList=[10,20,30,40]
(i) myList.append([50,60])
(ii) myList.extend([80,90]) 
Answer: (i) [10, 20, 30, 40, [50, 60]]
(ii) [10, 20, 30, 40, 80, 90]

Question: What will be the output of the following code segment?
myList=[1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
if i%2==0:
print(myList[i]) 
Answer: 1
3
5
7
9

Question: What will be the output of the following code segment?
(i) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)
(ii) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
(iii) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)
Answer: (i) [1, 2, 3]
(ii) [6, 7, 8, 9, 10]
(iii) [2, 4, 6, 8, 10]

Question: Write the suitable method’s name for the below conditions.
(i) Adds an element in the end of list.
(ii) Returns the index of first occurrence.
(iii) Adds contents of list2 to the end of list1.
Answer: (i) append ( ) (ii) index ( ) (iii) extend ( )

Question: Consider a list:
list1=[6,7,8,9]
What is the difference between the following operations on list1?
(i) list1 * 2
(ii) list1 *= 2
(iii) list1 = list1 * 2
Answer: (i) The statement will print the elements of the list twice, i.e. [6, 7, 8, 9, 6, 7, 8, 9]. However, list1 will not be altered.
(ii) This statement will change the list1 and assign the list with repeated elements, i.e. [6, 7, 8, 9, 6, 7, 8, 9] to list1.
(iii) This statement will also have same result as the statement ‘list1 *= 2’. The list with repeated elements, i.e. [6, 7, 8, 9, 6, 7, 8, 9] will be assigned to list1.

Question: Differentiate between append() and extend() functions of list.
Answer: Differences between append() and extend() functions of list 

Question: What possible output(s) are expected to be displayed on screen at the time of execution of the program from the following code?
List = [“Poem”, “Book”, “Pencil”, “Pen”]
List1 = List [2 : 3]
List[2] = “Scale”
print (List1)
Answer: [“Pencil”]

 Long Answer Type Questions

Question: Write a program to read elements of a list.
(i) The program should ask for the position of the element to be deleted from the list. Write a function to delete the element at the desired position in the list.
(ii) The program should ask for the value of the element to be deleted from the list. Write a function to delete the element of this value from the list.
Answer: (i) num = int(input(“Enter the number of elements: ”))
list1=list()
for i in range(num):
x=int(input(“Enter the element:
”))
list1.append(x)
print(“Original list: ”,list1)
print()
pos=int(input(“Enter the position of
the element you want to delete: ”))
del list1[pos]
print(“List after deletion:”,list1)
(ii) num = int(input(“Enter the number of elements: ”))
list1=list()
for i in range(num):
x=int(input(“Enter the element:
”))
list1.append(x)
print(“Original list: ”,list1)
x=int(input(“Enter the element you
want to delete: ”))
list1.remove(x)
print(“List after deletion: ”,list1)

Question: Write the best suited method’s name for the following conditions.
(i) Insert an element at specified position.
(ii) Add contents from one list to other.
(iii) Calculate the total length of list.
(iv) Reverse the contents of the list object.
Answer: (i) insert ( )
(ii) extend ( )
(iii) len ( )
(iv) reverse ( )

Question: Observe the following list and answer the questions that follows.
l1 = [45, 65,“The”, [65, “She”, “He”], 90, 12, “This”, 21]
(i) l1 [3 : 4] = [“That”, 54]
(ii) [l1 [4]]
(iii) l1 [:7]
(iv) l1 [1 : 2] + l1 [3 : 4]
Answer: (i) [45, 65, ‘The’, ‘That’, 54, 90, 12, ‘This’, 21]
(ii) [54]
(iii) [45, 65, ‘The’, ‘That’, 54, 90, 12]
(iv) [65, ‘That’]

Question:. The record of a student (Name, Roll No., Marks in five subjects and percentage of marks) is stored in the following list:
stRecord=[‘Raman’,‘A-36’,[56,98,99,72,69], 78.8]
Write Python statements to retrieve the following
information from the list stRecord.
(i) Percentage of the student
(ii)Marks in the fifth subject
(iii)Maximum marks of the student
(iv) Roll No. of the student
(v) Change the name of the student from ‘Raman’ to ‘Raghav’
Answer: (i) print(stRecord[3])
(ii) print(stRecord[2][4])
(iii) print(max(stRecord[2]))
(iv) print(stRecord[1])
(v) stRecord[0]=‘Raghav’

Question: What will be the output of the following statements?
(i) list1 = [12,32,65,26,80,10] list1.sort() print(list1)
(ii) list1 = [12,32,65,26,80,10] sorted(list1) print(list1)
(iii) list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::−2]
list1[:3] + list1[3:]
(iv) list1 = [1,2,3,4,5]
list1[len(list1)−1]
Answer: (i) [10, 12, 26, 32, 65, 80]
(ii) [12, 32, 65, 26, 80, 10]
(iii) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(iv) 5

Question: Write a program to read a list of elements. Modify this list, so that it does not contain any duplicate elements, i.e. all elements occurring multiple times in the list should appear only once.
Answer: list1=[]
num=int(input(“Enter the number of elements: ”))
for i in range(num):
x=int(input(“Enter the element: ”))
list1.append(x)
print(“New list: ”)
print(list(set(list1)))

Question: Write a program to read a list of elements. Input an element from the user that has to be inserted in the list. Also, input the position at which it is to be inserted. Write a user defined function to insert the element at the desired position in the list.
Answer: num=int(input(“Enter the number of elements: ”))
list1=list()
for i in range(num):
x=int(input(“Enter the element: ”))
list1.append(x)
print(“Original list: ”,list1)
print()
pos=int(input(“Enter the index
position: ”))
ele=int(input(“Enter thenewelement: ”))
list1.insert(pos, ele)
print()
print(“New list: ”,list1)

Question: Write a program to read a list of n integers and find their median.
Note The median value of a list of values is the middle one when they are arranged in order. If there are two middle values then take their average.
Hint You can use a built-in function to sort the list.
Answer: num=int(input(“Enter the number of
elements : ”))
list1=list()
for i in range(num):
x=int(input(“Enter the integer: ”))
list1.append(x)
print(“Original list:”,list1)
list1.sort()
print(“Sorted list: ”,list1)
c=len(list1)
if c%2 !=0:
med=c//2
print(“Median: ”,list1[med])
else:
a=list1[c//2]
b=list1[(c//2) − 1]
s=a+b
med=s/2
print(“Median: ”,med)
Question: In Python, list is a type of container in data structures, which is used to store multiple data at the same time. It can store integer, string as well as object in a single list. Lists are mutable which means they can be changed after creation. Each element of a list is assigned a number its position or index. The first index is 0, the second index is 1, the third index is 2 and so on.
Based on the above information, answer the following questions.
(i) List is defined by which type of bracket?
(ii) List contains a sequence of what type of elements?
(iii) Lists are mutable. What is it mean?
(iv)Which method is also used to create list of characters and integers through keyboard?
(v) How to represent the first index of list?
Answer: (i) []
(ii) Heterogeneous
(iii) Lists are mutable, which means they can be changed
after creation
(iv) list ()
(v) 0