Python/MCQ on List in Python Sample Test,Sample questions

Question:
 Identify data type of ‘T’ in following line of Code:
T = list(tuple([1,2,3]))
print(type(T))

1.Tuple

2.List

3.Nested List

4.None of the above


Question:
 List and String are different

1.in reference to their indexing

2. in reference to data type of elements they contain

3.Both of the above

4.None of the above


Question:
 List can have elements of _____________ data types.

1.Same

2.Different

3.Both of the above

4.None of the above


Question:
 Which command is used to add an element in List named L1

1.L1.add(4)

2.L1.append(4)

3. L1.new(4)

4.None of the above


Question:
 Which mathematical operator is used to concatenate list?

1.+

2.//

3.**

4.None of the above


Question:
 Write the output of the following :
L = ['Amit', 'anita', 'Sumant', 'Zaid']
print(max(L))

1.Zaid

2.Sumant

3.anita

4.Amit


Question:
 Write the output of the following :
L = [11, 21, 31, 41]
L.extend([51,62,73,84])
print(len(L))

1.8

2.5

3.4

4.Error


Question:
 Write the output of the following :
L = [[5, 7, 9, 1 ], [12, 23, 4, 9]]

for r in L:
    r.reverse( )
    for e in r:
        print(e, end = ” “)

1.1 9 7 5 9 4 23 12

2.1 9 7 5 9 4 23 12

3.Error

4.None of the above


Question:
 Write the output of the following code :
>>>L=[“Amit”,”Sumit”,”Naina”]
>>>print(L[1:-1])

1.[‘Sumit’]

2.[a]

3.[Naina]

4.None of the above


Question:
 Write the output of the following code :
L=[0.5 * x for x in range(4)]
print(L)

1.[0.0, 0.5, 1.0, 1.5]

2. (0,.5, 1, 1.5)

3. [0.0, 0.5, 1.0, 1.5, 2.0]

4.Error


Question:
 Write the output of the following:
T = [1,2,3,4]
T1 = [3,4,5,6]
T2 = T + T1
print(T2)

1.[1, 2, 3, 4, 5, 6]

2. [1, 2, 3, 4, 3, 4, 5, 6]

3.[4, 6, 8, 10]

4.Error


Question:
 Write the output of the following:
T = [1,2,3,4]
T1=T
T[0] = “A”
print(T)
print(T1)

1.['A', 2, 3, 4] [1, 2, 3, 4]

2.['A', 2, 3, 4] ['A', 2, 3, 4]

3.[1, 2, 3, 4] [1, 2, 3, 4]

4.Error


Question:
del statement can delete the following from the List?

1.Single Element

2.Multiple Elements

3.All elements along with List object

4.All the above


Question:
Fill in the blanks with same word in both places
>>> import __________
>>> list1 = [1,2,3,4,5]
>>> list2 = _________copy(list1)
>>> list2

1.copy

2.pickle

3.math

4.None of the above


Question:
How many elements will be there in list ‘L’
L = [[p, q] for p in (0, 4) for q in (0, 4)]

1.2

2.4

3.8

4.16


Question:
If we try to concatenate a list with elements of some other data type, _____________ occurs.

1.SyntaxError

2.SyntaxError

3.TypeError

4.None of the above


Question:
If we try to concatenate a list with elements of some other data type, _____________ occurs.

1.SyntaxError

2.SyntaxError

3.TypeError

4.None of the above


Question:
If we try to concatenate a list with elements of some other data type, _____________ occurs.

1.SyntaxError

2.SyntaxError

3.TypeError

4.None of the above


Question:
If we try to concatenate a list with elements of some other data type, _____________ occurs.

1.SyntaxError

2.SyntaxError

3.TypeError

4.None of the above


Question:
Name the operator which is used in the following print statement.

1.Concatenation

2.Repetition

3.Membership

4.None of the above


Question:
remove( ) function removes the _______________ occurrences of an element from the list

1.all

2.first

3.last

4.None of the above


Question:
The following statements is showing ______ operation in List.
L1 = [1,2,3,4]
L2 = [1,2,3,4]
L = L1 + L2

1. Replication of List

2.Concatenation of String

3.Indexing of String

4.None of the above


Question:
Traversing a list can be done with the help of _____

1. loop

2.if

3.if–elif

4. None of the above


Question:
What type of error is returned by the following statement?
T = [1,2,3,4]
print(T.index(9))

1.IndexError

2.TypeError

3.ValueError

4.None of the above


Question:
What we call the operation which is used to extract particular range from a sequence.

1.Slicing

2.range

3.Indexing

4.Replication


Question:
Which function returns the length of a list?

1.Len( )

2.length( )

3. len( )

4.Length( )


Question:
Which mathematical operator is used for repetition?

1.*

2.**

3.+

4.//


Question:
Which of the following command will insert 7 in third position of List L.

1.L.insert(3, 7)

2.L.insert(2, 7)

3.L.add(3, 7)

4.L.append(3, 7)


Question:
Which of the following function creates the new list?

1.sort( )

2.sorted( )

3. reverse( )

4.All the above


Question:
Which of the following function is used to shuffle the list ?

1.random( )

2.swap( )

3.shuffle( )

4.None of the above


Question:
Which of the following is not list operation?

1. Indexing

2.Slicing

3.Dividing

4.Concatenation


Question:
Which of the following is true about List data type in Python?

1. List is a Sequence data type

2.List is mutable

3. List can have elements of different data type

4.All the above


Question:
Which of the following statement will create list?

1.a. L1=list( )

2.L1=[1,2,3,4]

3.Both of the above

4.None of the above


Question:
Which of the following statement will generate the square of given list L ? L = [1, 2, 3, 4, 5]

1.[x ** 2 for x in L

2. [x * 2 for x in L]

3. [x ^ 3 for x in L

4.None of the above


Question:
Which of the following statement will return first element from right of list ‘L’?

1.L[0]

2.L[-1]

3.L[1]

4.None of the above


Question:
Which of the following statement will reverse the list L1?

1.L1[ : : 1]

2. L1[-1 : : -1]

3.L1[: : -1]

4.None of the above


Question:
Which of the following will give output as [21,2,9,7] ? if list L = [1,21,4,2,5,9,6,7]

1.print(L[1 : 8 : 2])

2.print(L[1 : : 2])

3.Both of the above

4.None of the above


Question:
Which operation of List is shown in following lines?
L1 = [1, 2, 3, 4, 5, 6, 7, 8]
print(L1[3 : 6])

1. Concatenation

2.Repetition

3.Slicing

4.None of the above


Question:
Which operator helps to check whether an element is present in list or not?

1.+

2. in

3. **

4.None of the above


Question:
Which statement will give the same output?
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]

1. print(len(list1 + list2))

2. print(len(list1) + len (list2))

3.print(list2[3])

4.All the above


Question:
Write the output of the following
L = ["Amit", 'Sumit', 'Ravi']
print("@".join(L))

1.@Amit

2.Amit@Sumit@Ravi

3.Amit@Sumit@Ravi@

4.None of the above


Question:
Write the output of the following
L = ["Amit", 'Sumit', 'Ravi']
print(L[0][1])

1.A

2.Amit

3.s

4.m


Question:
Write the output of the following
L = [14, 2, 3, 16, 15]
L[1:4] = [5, 4, 8]
print(L)

1.[14, 5, 4, 8, 15]

2. [14, 5, 4, 8, 2, 3, 16, 15]

3.Error

4.None of the above


Question:
Write the output of the following
L1 = ['C++', 'C-Sharp', 'Visual Basic']
L2 = [name.upper() for name in L1] 
L3 = [name for name in L1] 
if(L2[2][0] == L3[2][0]):
 print("YES")
else:
 print("N0")

1.NO

2.yes

3.Error

4.None of the above


Question:
Write the output of the following
list1=[3,2,5,7,3,6]
list1.insert(6,3)
print(list1)

1.[3, 2, 5, 6, 7, 3, 6]

2. [3, 2, 5, 6, 3, 6]

3.[3, 2, 5, 7, 3, 6, 3]

4.None of the above


Question:
Write the output of the following :
D = list[ ]
print(len(D))

1.0

2.1

3.SyntaxError

4.ValueError


Question:
Write the output of the following :
D = [1,2,3]
D1 = D
D.append(4)
print(D1)

1.[1, 2, 3, 4]

2.[1, 2, 3]

3.Error

4.None of the above


Question:
Write the output of the following :
def listchange(L):
L.append(45)
return
L1 = [1, 2, 3, 4]
listchange(L1)
print(L1)

1.[1, 2, 3, 4]

2.[1, 2, 3, 45]

3. [1, 2, 3, 4, 45]

4.None of the above


Question:
Write the output of the following :
L = “123456”
L = list(L)
print(type(L[0]))

1.class ‘str’

2. class ‘int’

3.1

4.Error


Question:
Write the output of the following :
L = [1,2,3,4,5,6,7,8,9,10]
print(L[L[3]])

1.3

2.4

3.5

4.6


Question:
Write the output of the following :
L = [11, 22, 33, 44, 55, 66]
for i in range(1, 6):
   L[i - 1] = L[i]*2
for i in range(0, 4):
   print(L[i], end = " ")

1.44 66 88 110

2.22 33 44 55

3.11 22 33 44

4.Error


Question:
Write the output of the following :
L = [[1,2,3,5,6,7,[1,[2,3]]]]
print(len(L))

1.4

2.3

3.2

4.1


Question:
Write the output of the following :
L1 = [1, 2, 3, 4, 5]
L2 = [9, 8, 7, 6, 5]
S= [L1 + 3 for L1 in L2]
print(S)

1.12, 11, 10, 9, 8]

2. [1, 2, 3, 4, 5, 6, 7, 8, 9]

3. [4, 5, 6, 7, 8]

4.Error


Question:
Write the output of the following :
L1 = [1, 2, 3]
L2 = [9, 8]
S= [m * n for m in L1 for n in L2]
print(S)

1.[9, 8, 18, 16, 27, 24]

2.[9, 18, 27, 8, 16, 24]

3.[8, 9, 16, 18, 24, 27]

4.Error


Question:
Write the output of the following :
L1 = [1, 2, 3]
L2 = [9, 8]
S= [n + m for m in L1 for n in L1]
print(S)

1.[2, 3, 4, 3, 4, 5, 4, 5]

2. [1, 2, 3, 2, 3, 4, 3, 4, 5]

3.[2, 3, 4, 3, 4, 5, 4, 5, 6]

4.Error


Question:
Write the output of the following :
L1 = [1,2,3]
L2=[5,6,7]
L1 + L2
print(L1)

1.[1, 2, 3, 4, 5, 6, 7]

2.[1, 2, 3, 5, 6, 7]

3. [1, 2, 3]

4.None of the above


Question:
Write the output of the following :
L= [1,2,3,4,5]
m = [m + 3 for m in L]
print(m)

1.[4, 5, 6, 7, 8, 9]

2.[4, 5, 6, 7, 8, 9, 10]

3.[4, 5, 6, 7, 8]

4.Error


Question:
Write the output of the following :
L= [1,2,3,4,5]
m = [m and 1 for m in L]
print(m)

1.[1, 2, 3, 4, 5]

2.[1, 1, 1, 1, 1]

3.[1, 0, 1, 0, 1

4.None of the above


Question:
Write the output of the following :
L=["Amit","Sumit","Naina"]
L1=["Sumit"]
print(L - L1)

1.[“Amit” , “Naina”]

2.[“Amit” , “Naina”, “Sumit”]

3.Show Error

4.Error


Question:
Write the output of the following :
L=[2 * x for x in range(3,14,3)]
print(L)

1.[6, 12, 18, 24]

2.[6, 12, 18]

3.[6, 12, 18, 24, 30]

4.Error


Question:
Write the output of the following code :
>>> L=[‘w’,’e’,’l’,’c’,’o’,’m’,’e’]
>>> print(len(L))

1.7

2.8

3.9

4.None


Question:
Write the output of the following code :
>>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”,123]
>>> print(max(L))

1.Longest Word

2.Zee

3.Amit

4.Error


Question:
Write the output of the following code :
>>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”]
>>> print(max(L))

1.Zee

2. Longest Word

3. Error

4.None of the above


Question:
Write the output of the following code :
>>>L=list(“www.csiplearninghub.com”)
>>>print(L[20 : 0])

1.Error

2.No Value

3.None

4.[ ]


Question:
Write the output of the following code :
>>>L=[1,2,3,4,5,[6,7,8]]
>>>print(L[5])

1.[6, 7, 8]

2.6, 7, 8

3.Error

4.6


Question:
Write the output of the following code :
>>>L=[1,5,9]
>>>print(sum(L),max(L),min(L))

1.15 9 1

2.Error

3.Max and Min are only for String Value

4.None of the above


Question:
Write the output of the following code :
>>>L=[“Amit”,”Sumit”,”Naina”]
>>>print(L[-1][-1])

1.[Naina]

2.[a]

3.a

4.None of the above


Question:
Write the output of the following code :
L= [1*x for x in range(10,1,-4)]
print(L)

1. [10, 6, 2]

2.[10, 7, 4]

3.Error

4.None of the above


Question:
Write the output of the following code :
L=list(“www.csiplearninghub.com”)
print(L[20 : -1])

1.[‘c’ , ‘o’]

2.[‘c’ , ‘o’ , ‘m’]

3. (com)

4.Error


Question:
Write the output of the following code :
L=[1,2,3,4,5]
for i in L:
     print(i,end=” “)
     i=i+1

1.1, 2, 3, 4, 5

2.1, 3, 5

3.Error

4.None of the above


Question:
Write the output of the following code :
L=[‘a’ * x for x in range(4)]
print(L)

1.[‘ ‘ , ‘a’ , ‘aa’ , ‘aaa’]

2. [‘a’, ‘aa’, ‘aaa’]

3.Error

4.None of the above


Question:
Write the output of the following code :
L=[“Amit”,”Sumit”,”Naina”]
L1=[“Sunil”]
print(L + L1)

1.[‘Amit’ , ‘Sumit’ , ‘Naina’ , [‘Sunil’]]

2.[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]

3.List can not concatenate

4.None of the above


Question:
Write the output of the following code :
L=[“Amit”,”Sumit”,”Naina”]
print(L**2)

1. Error

2. [“Amit”,”Sumit”,”Naina”][“Amit”,”Sumit”,”Naina”]

3. [“Amit”,”Sumit”,”Naina”]

4.[“Amit”,”Sumit”,”Naina”,”Amit”,”Sumit”,”Naina”]


Question:
Write the output of the following code :
L=[“Amit”,”Sumit”,”Naina”]
print(L*2)

1. [‘Amit’, ‘Sumit’, ‘Naina’, ‘Amit’, ‘Sumit’, ‘Naina’]

2.[“Amit” , “Sumit” , “Naina”]

3.Error

4.None of the above


Question:
Write the output of the following code :
list(“welcome”)

1.[‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’]

2. (‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’)

3.[‘welcome’]

4.None of the above


Question:
Write the output of the following.
T = [1,2,3,4]
T1=[5,6,7]
L=T.append(T1)
print(L)

1.None

2.[1, 2, 3, 4, [5, 6, 7]]

3. [ ]

4.Error


Question:
Write the output of the following:
L = ['A', 'S', 'R']
L = L + L*2
print(L)

1.[‘A’, ‘S’, ‘R’, ‘2A’, ‘2S’, ‘2R’]

2. [‘A’, ‘S’, ‘R’, ‘A’, ‘S’, ‘R’, ‘A’, ‘S’, ‘R’]

3.[‘A’, ‘S’, ‘R’]

4.Error


Question:
Write the output of the following:
L = [1,2,3,4,5,6,7,8,9,10]
print(L[len(L) - 1])

1.9

2.1

3.Error

4.None of the above


Question:
Write the output of the following:
L = [11, 21, 31, 41]
L.append([51,62,73,84])
print(len(L))

1.8

2.5

3.4

4.None of the above


Question:
Write the output of the following:
L = [23, 45, 65, 32, 3]
L.insert(L[4], 'Monitor')
print(L)

1.[23, 45, 65, ‘Monitor’, 32, 3]

2.[23, 45, 65, 32, ‘Monitor’, 3]

3.[23, 45, 65, 32, 3, ‘Monitor’]

4.None of the above


Question:
Write the output of the following:
L = [[5, 7, 9, 1 ], [12, 23, 4, 9]]
for r in L:
    r.sort()
    for e in r:
        print(e, end = ” “)

1.1 5 7 9 4 9 12 23

2. 1 4 5 7 9 9 12 23

3. 9 7 5 1 23 12 9 4

4.None of the above


Question:
Write the output of the following:
L = [[p, q] for p in (0, 4) for q in (0, 4)]
print(L[0])

1.[0]

2. [0, 4]

3. [4, 4]

4. [0, 0]


Question:
Write the output of the following:
L =[['Physics',101],['Chemistry',202], ['Maths',303],45, 6, 'j'] 
print(len(L))

1.3

2.4

3.5

4.6


Question:
Write the output of the following:
L=["Amit","Sumit","Naina"]
L1=["Sunil"]
print(L + L1)

1.[“Amit” , “Sumit” , “Naina” , [“Sunil”] ]

2.[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]

3.Error

4.[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’][‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]


Question:
Write the output of the following:
L=[13, 12, 15, 27, 3, 46]
list1.pop(3)
print(L)

1.[13,12,15, 27, 46]

2.[13, 12, 15, 3, 46]

3.[13, 12, 15, 27, 3]

4.None of the above


Question:
Write the output of the following:
list1=[3,2,5,7,3,6]
list1.remove(3)
print(sum(list1))

1.23

2.20

3.15

4.None of the above


Question:
Write the output of the following:
print(1 in [[1],2,3])

1.True

2.False

3.Error

4.None of the above


Question:
Write the output of the following:
print(len(tuple[1]))

1.1

2.0

3.Error

4.None of the above


Question:
Write the output of the following:
print([] * 2 )

1.[ ]

2.0

3.Error

4.None of the above


Question:
Write the output of the following:
T = [1,2,3,4]
T1 = [3,4,5,6]
T2 = T.append(T1)
print(T2)

1. [1, 2, 3, 4, [3, 4, 5, 6]]

2.[1, 2, 3, 4, 3, 4, 5, 6]

3.None

4.None of the above


Question:
Write the output of the following:
T=(1,2,3,4,5.5)
L = list(T)
print(L*2)

1.[2, 4, 6, 8, 11]

2. [1, 2, 3, 4, 5.5, 1, 2, 3, 4, 5.5]

3.Error

4.None of the above


Question:
Write the output of the following:
T=(1,2,3,4,5.5)
L = list(T)
print(L[3]*2.5)

1.Error

2.10

3.10.0

4.4


Question:
Write the output of the following:

1. Error

2.14 + 9 -1

3.23

4.24


Question:
Write the output of the following:

1. Error

2.14 + 9 -1

3.23

4.24


Question:
Write the output of the following:

1. Error

2.14 + 9 -1

3.23

4.24


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Python Practice Papers
  53. python mcq question and answer
  54. Test
Learn MCQ on List in Python,Learn Python Objetive choice questions and answers,Python Multiple choice questions and answers,Python objective, Python questions , Python answers,Python MCQs questions and answer
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!