Showing posts with the label Lists

Program to swap the first half elements with the second half elements of a list of numbers.

Q. Program to swap the first half elements with the second half elements of a l…

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

Q. Differentiate between append() and extend() functions of list. Answer :- The…

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

Q. Read a list of n elements. Pass this list to a function which reverses this …

Write a program to read elements of a list. The program should ask for the position of the element to be deleted from the list.

Q. Write a program to read elements of a list. a)The program should ask for the…

Write a program to read a list of elements. Input an element from the user that has to be inserted in the list.

Q. Write a program to read a list of elements. Input an element from the user t…

Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements.

Q. Write a program to read a list of elements. Modify this list so that it does…

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

Q. Write a program to read a list of n integers and find their median. Note:   …

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

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

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

Q. Write a function that returns the largest element of the list passed as para…

Write a program to read a list of n integers (positive as well as negative).

Q. Write a program to read a list of n integers (positive as well as negative).…

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

Q. Write a program to find the number of times an element occurs in the list. A…

The record of a student (Name, Roll No., Marks in five subjects and percentage of marks) is stored in the following list:

Q. The record of a student (Name, Roll No., Marks in five subjects and percenta…

Consider a list: list1 = [6,7,8,9] What is the difference between the following operations on list1:

Q. Consider a list: list1 = [6,7,8,9] What is the difference between the follow…

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

Q. What will be the output of the following code segment: a. myList = [1,2,3,4,…

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

Q. What will be the output of the following code segment: myList = [1,2,3,4,5,6…

What will be the elements of myList after the following two operations:

Q. Consider the following list myList. What will be the elements of myList afte…

list1 = [12,32,65,26,80,10] list1.sort() print(list1)

Q. What will be the output of the following statements? i.list1 = [12,32,65,26,…

Load More That is All