Multiple Choice Questions

Question 1

List can contain values of these types:

  1. integers
  2. floats
  3. lists
  4. tuples
  5. all of these ✓

Question 2

Which of the following will create an empty list?

  1. L = [ ] ✓
  2. L = list(0)
  3. L = list( ) ✓
  4. L = List(empty)

Question 3

Which of the following will return the last element of a list L with 5 elements?

  1. L[5]
  2. L[4] ✓
  3. L[-1] ✓
  4. L[6]

Question 4

If L = [1, 2] then L * 2 will yield

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

Question 5

If L1 = [1, 3, 5] and L2 = [2, 4, 6] then L1 + L2 will yield

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

Question 6

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[1 : 4] return?

  1. [10, 20, 30, 40]
  2. [20, 30, 40, 50]
  3. [20, 30, 40] ✓
  4. [30, 40, 50]

Question 7

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[2 : -2] return?

  1. [10, 20, 30, 40]
  2. [20, 30, 40, 50]
  3. [20, 30, 40]
  4. [30, 40, 50] ✓

Question 8

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-4 : -1] return?

  1. [20, 30, 40]
  2. [30, 40, 50]
  3. [40, 50, 60] ✓
  4. [50, 60, 70]

Question 9

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-3 : 99] return?

  1. [20, 30, 40]
  2. [30, 40, 50]
  3. [40, 50, 60]
  4. [50, 60, 70] ✓

Question 10

To find the last element of list namely ‘smiles’ in Python, ………. will be used.

  1. smiles[0]
  2. smiles[-1] ✓
  3. smiles[lpos]
  4. smiles[:-1]

Question 11

Out of the following, what is correct syntax to copy one list into another?

  1. listA = listB[ ]
  2. listA = listB[:] ✓
  3. listA = listB[ ]( )
  4. listA = list(listB) ✓

Question 12

What is printed by the Python code?
    print(list(range(3)))

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

Question 13

Which of the following commands will create a list?

  1. listl = list( )
  2. listl = [ ]
  3. listl = list([1, 2, 3])
  4. all of these ✓

Question 14

What is the output when we execute list(“hello”)?

  1. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] ✓
  2. [‘hello’]
  3. [‘llo’]
  4. [‘olleh’]

Question 15

What gets printed?

names = ['Hasan', 'Balwant', 'Sean', 'Dia']
print(names[-1][-1])
  1. H
  2. n
  3. Hasan
  4. Dia
  5. a ✓

Question 16

What is the output of the following

l = [None] * 10
print(len(l))
  1. 10 ✓
  2. 0
  3. Syntax Error
  4. None

Question 17

Consider the list aList – [“SIPO”, [1, 3, 5, 7] ]. What would the following code print?

print(aList[0][1], aList[1][1])
  1. S, 3
  2. S, 1
  3. I, 3 ✓
  4. I, 1

Question 18

Which of the following is a standard Python library function and not an exclusively list function?

  1. append( )
  2. remove( )
  3. pop( )
  4. len( ) ✓

Question 19

Which of the following can add only one value to a list?

  1. add( )
  2. append( ) ✓
  3. extend( )
  4. none of these

Question 20

Which of the following can add a list of elements to a list?

  1. add( )
  2. append( )
  3. extend( ) ✓
  4. none of these

Question 21

Which of the following will always return a list?

  1. max( )
  2. min( )
  3. sort( )
  4. sorted( ) ✓

Question 22

Which of the following can delete an element from a list if the index of the element is given?

  1. pop( )
  2. remove( )
  3. del ✓
  4. all of these

Question 23

Which of the following can delete an element from a list, if its value is given?

  1. pop( )
  2. remove( ) ✓
  3. del
  4. all of these

Question 24

Which of the following searches for an element in a list and returns its index?

  1. search( )
  2. find( )
  3. index( ) ✓
  4. lsearch( )

Question 25

Which of the following can copy a list to another list?

  1. list( ) ✓
  2. new( )
  3. copy( ) ✓
  4. = operator


Discover more from EduGrown School

Subscribe to get the latest posts sent to your email.