Lists
Class 11 · Computer Science · 16 Questions
What will be the output of the following statements?
Consider the following list myList. What will be the elements of myList after the following two operations: myList = [10,20,30,40]
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])
What will be the output of the following code segment:
Differentiate between append() and extend() functions of list.
Consider a list: list1 = [6,7,8,9] What is the difference between the following operations on list1:
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.
Write a program to find the number of times an element occurs in the list.
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.
Write a function that returns the largest element of the list passed as parameter.
Write a function to return the second largest number from a list of numbers.
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 an built-in function to sort the list
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.
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.
Write a program to read elements of a list.
Read a list of n elements. Pass this list to a function which reverses this list in-place without creating a new list.