Data Types in Python Online Quiz 2021

Data Types in Python Online Quiz 2021


Which statement is correct?

A. List is immutable && Tuple is mutable
B. List is mutable && Tuple is immutable
C. Both are Mutable.
D. Both are Immutable


The list is mutable and Tuple is immutable. A mutable data type means that a python object of this type can be modified. An immutable object can’t. So, Option B is correct.


Suppose a list with name arr, contains 5 elements. You can get the 2nd element from the list using:

  1. arr[-2]
  2. arr[2]
  3. arr[-1]
  4. arr[1]

arr[0] will give first element while second element is given by arr[1] So, Option 4 is correct


How to get the last element of list in python? Suppose we have list with name arr, which contains 5 elements.

  1. arr[0]
  2. arr[5]
  3. arr[last]
  4. arr[-1]

The arr[-n] syntax gets the nth-to-last element. So arr[-1] gets the last element, arr[-2] gets the second to last, etc. So, Option 4 is correct.


How to copy one list to another in python?

  1. l1[] = l2[]
  2. l1[] = l2
  3. l1[] = l2[:]
  4. l1 = l2



Options 1 and 2 syntaxes are incorrect while 4 will point both names to the same list. Hence C is the best way to copy one list to another. So, Option C is correct.

Leave a Reply