80 solutions available
Question 1Assertion (A): List in Python is a collection of values of any type.Reasoning (R): In lists, you can change the elements of a list in...
Question 2Consider the given two statements:T1 = [3, 9, 0, 1, 7]T2 = [5, 1, 0, 7, 5.5]Assertion (A): Output of print(len(T1) == len(T2)) is...
Question 3Assertion (A): List traversal in Python is done through slicing and using for loop also.Reasoning (R): Traversal can be done only through...
Question 4Assertion (A): In Python, list is an immutable collection of data.Reasoning (R): Mutable means that any change or alteration in data is...
Question 5Assertion (A): The position of each element in the list is considered as its index.Reasoning (R): Indexing in a list can be positive and...
Question 6Assertion (A): sort() method sorts the objects of list in ascending order.Reasoning (R): Defining sort() method with reverse=True as an...
Question 7Assertion (A): An empty list can be created using list() method.Reasoning (R): The following snippet—>>>L1 = list()...
Question 8Assertion (A): List is mutable data type.Reasoning (R): In-place change is not possible in list elements.Both A and R are true and R is the...
Question 9Assertion (A): List slices are the sub-part of a list extracted out.Reasoning (R): In Python, Slice operator[:] is used to select a range...
Question 1List in Python is classified as a Sequence data type.
Question 2A list consists of elements of heterogeneous type.
Question 3Lists are indexed by a/an integer data type.
Question 4Elements of a list are enclosed in square[] brackets.
Question 5Lists are mutable, you can update or edit the list.
Question 6remove() method is used to delete elements from a list if index is not known.
Question 7pop() and del command methods are used to delete elements from a list if index is known.
Question 8The append() method adds a single item to the existing list at the end.
Question 9You can compare two lists by using comparison operators.
Question 10The replication(*) operator replicates a list.
Question 11The assignment(=) operator creates a reference of the original list that shares the same memory location.
Question 12The insert() function inserts item into the list at the specified index.
Question 13The sort() function arranges the elements of the list either in ascending or descending order.
Question 1Consider the following statement:List = ['h', 'o', 'i'] The length of the above list is:530None of these
Question 2The list L1 contains [3, 4, 5, 6, 6, 8, 0]. What will be the output of the following expression?print(L1 [-1])0358
Question 3Which of the following statements is correct about list?List can contain values of mixed data types.List can contain duplicate values.A...
Question 4Which operator can be used with list?innot inBoth 1 & 2Arithmetic Operators only
Question 5Which of the following commands will create a list?List1=list ()List1= []List1=[1,2,3,"a"]All of these
Question 6What is the use of append() function in list?It adds an item to the end of the list.It adds an item at the beginning of the list.It adds an...
Question 7Select the output of the following expression:str1 = "pen" print(list(str1))['p', 'e', 'n' ][pen][p/e/n]{ "pen" }
Question 8The sequential accessing of each of the elements in a list is called:List IndexingList TraversalList SlicingList Accessing
Question 9Consider the following lists:L1 = ["this", "is", "a", "list"] L2 = ["this", "is", "another list"]Which of the following statements will...
Question 10Consider the following code:>>>A = [10, 20, 30, 40] >>>B = A.copy() >>>A[2] = 50 >>>BWhich of the...
Question 11Consider the following lists:A = [1,2] B = [1,2] What will be the output of the following?print(A==B)TrueFalseErrorNo output
Question 12Which of the following functions will return the first occurrence of the specified element in a list?sort()value()index()Sorted()
Question 13Given A = "[22, 4.88, "India", "T"]" the data type of A isListStringDictionaryTuple
Question 14Find the output of the following code:number = [1, 5, 7, 0, 4] print(number[2:3]) [5][7][7,0]None of these
Question 15What will be the output of the following operation?L1 = [1,2] L2 = [3, 4] (L1 + L2)*2[2, 4, 6, 8][1, 2, 3, 4, 1, 2, 3, 4][1, 3, 4, 4][3,...
Question 1What are the various ways to create a list?
Question 2What are the similarities between strings and lists?
Question 3Why are lists called mutable data type?
Question 4Define the following functions:(a) len()(b) append()(c) extend()(d) pop()(e) remove()(f) del(g) sort()(h) sorted()(i) copy()(j) count()(k)...
Question 5What is the difference between insert() and append() methods of a list?
Question 6Suppose L = [10, ["few", "facts", "fun"], 3, 'Good']Consider the above list and answer the following:(a) L[3:](b) L[::2](c) L[1:2](d) L[1]...
Question 7Find the output of the following:L1=[1, 2, 3] L2=[4, 5, 6] print(L1+list ("45") ) print(L1.pop()) L1.remove (2) print(L1) L1.extend (L2)...
Question 8(a)What will be the output of the following statement?list1 = [12, 32, 65, 26, 80, 10] list1.sort() print(list1)Output[10, 12, 26, 32, 65,...
Question 8(b)What will be the output of the following statement?list1 = [12, 32, 65, 26, 80, 10] sorted(list1) print(list1)
Question 8(c)What will be the output of the following statement?list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] list1[::-2] list1[:3] + list1[3:]
Question 8(d)What will be the output of the following statement?list1 = [1, 2, 3, 4, 5] list1[len(list1)-1]
Question 9What 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...
Question 10(a)What will be the output of the following code segment?myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] del myList[3:] print(myList)
Question 10(b)What will be the output of the following code segment?myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] del myList[:5] print(myList)
Question 10(c)What will be the output of the following code segment?myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] del myList[::2] print(myList)
Question 11Write the output of the following Python program code:Str2 = list("Cam@123*") for i in range(len(Str2)-1): if i==5: Str2[i] =...
Question 12Differentiate between append() and insert() methods of list.
Question 13Write 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...
Question 14Write a program to find the largest and the second largest elements in a given list of elements.Solutionnums = eval(input("Enter the list:...
Question 15Write 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...
Question 16Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements...
Question 17Write a program to create a list of elements. Input an element from the user that has to be inserted in the list. Also, input the position...
Question 18Write a program to read elements of a list and do the following:(a) The program should ask for the position of the element to be deleted...
Question 19Write a program that accepts elements of a list S and adds all the odd values and displays the sum.SolutionS = eval(input("Enter list: "))...
Question 20Write a program to calculate mean of a given list of numbers.Solutionnumbers = eval(input("Enter a list: ")) if len(numbers) == 0:...
Question 21WAP in Python to delete all duplicate elements in a list.For example,If list is: [5, 2, 4, -5, 12, 2, 7, 4]After deleting duplicate...
Question 22Write a program to calculate the minimum elements of a given list of numbers.Solutionl = eval(input("Enter a list: ")) m = min(l)...
Question 23Write a code to calculate and display total marks and percentage of a student from the given list storing marks of a...
Question 24WAP to multiply an element by 2 if it is odd index for a given list containing both numbers and strings.Solutionmixed = eval(input("Enter...
Question 25WAP to count the frequency of an element in a given list.Solutionmy_list = eval(input("Enter the list: ")) c = int(input("Enter the...
Question 26WAP to shift elements of a list so that first element moves to the second index and second index moves to the third index, etc., and last...
Question 27An array Num contains the following elements:3, 25, 13, 6, 35, 8, 14, 45Write a function to swap the content with next value divisible by...
Question 28The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list:studRecord =...
Question 1Python lists are mutable.
Question 2Lists are depicted through curly brackets only.
Question 3A list can contain heterogeneous values.
Question 4We can create an empty list by using list() function.
Question 5A list is stored in memory as integer.
Question 6The command [1,2,3,4,]<[9,1] will give the output as True.
Question 7List[a:b] will give the elements between a and b.
Question 8The append() function is used to add a value in a list at any place.
Question 9index() function will return the index of first matched item from the list.
Question 10extend() function is used to add multiple list items in a list.