Lists NCERT Solution || Lists Class 11 Solution || Lists Python Class 11 CS Solution || Lists Computer Science Solution || NCERT Lists Solution || Lists in Python Class 11 CS || Lists in Python Solution


Note :-  Please Click on Question to get Answer of that Question !!


Exercise


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



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



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



Q4. What will be the output of the following code segment:

a. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)

b. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)

c. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)



Q5. Differentiate between append() and extend() functions of list.


Q6. Consider a list:
list1 = [6,7,8,9]
What is the difference between the following operations on list1:
a. list1 * 2
b. list1 *= 2
c. list1 =  list1 * 2



Q7. 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.
a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll no. of the student
e) Change the name of the student from ‘Raman’ to ‘Raghav’



Programming Problems:-



Q1. Write a program to find the number of times an element occurs in the list.


Q2. Write a program to read a list of n integers (positive as well as negative). Create two new lists, one having all positive numbers and the other having all negative numbers from the given list.  Print all three lists.


Q3. Write a function that returns the largest element of the list passed as parameter.


Q4. Write a function to return the second largest number from a list of numbers.


Q5. Write a program to read a list of n integers and find their median.


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


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


Q8. Write a program to read elements of a list.
a)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.
b)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.



Q9. Read a list of n elements. Pass this list to a function which reverses this list in-place without creating a new list.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post