Quiz: Tuple

To View Tricks: Login Required

Number of Questions: 10

Question: 6 -

What will be the output of below Python code?

tupl=()
tupl1=tupl*2
print(len(tupl1))

Options:
  1. Error as tuple object has no attribute to len

  2. 2

  3. 0

  4. 1

  5. Answer:

    0

    Solution not available.

Question: 7 -

Which of the following two Python codes will give same output?
(i) print(tupl[:-1])
(ii) print(tupl[0:5])
(iii) print(tupl[0:4])
(iv) print(tupl[-4:])

If tupl=(5,3,1,9,0) 

Options:
  1. ii, iv

  2. i, ii

  3. i, iv

  4. i, iii

  5. Answer:

    i, iii

    Solution not available.

Question: 8 -

What will be the output of below Python code?

tupl=("annie","hena","sid")
print(tupl[-3:0])

Options:
  1. None

  2. ("annie")

  3. ()

  4. Error as slicing is not possible in tuple.

  5. Answer:

    ()

    Solution not available.

Question: 9 -

What will be the output of below Python code?

tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)

Options:
  1. ([2,1],"abc",0,9)

  2. ([2,3],"abc",0,9)

  3. Error

  4. ([1,3],"abc",0,9)

  5. Answer:

    ([2,1],"abc",0,9)

    Solution not available.

Question: 10 -

Which of the following options will not result in an error when performed on tuples in Python where tupl=(5,2,7,0,3)?

Options:
  1. tupl.append(2)

  2. tupl.sort()

  3. tupl1=tupl+tupl

  4. tupl[1]=2

  5. Answer:

    tupl1=tupl+tupl

    Solution not available.