Quiz: Tuple

To View Tricks: Login Required

Number of Questions: 10

Question: 1 -

Choose the correct option with respect to Python.

Options:
  1. Tuples are immutable while lists are mutable.

  2. Tuples are mutable while lists are immutable.

  3. Both tuples and lists are mutable.

  4. Both tuples and lists are immutable.

  5. Answer:

    Tuples are immutable while lists are mutable.

    Solution not available.

Question: 2 -

What will be the output of below Python code?

tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)

Options:
  1. (4,8,6)

  2. (2,4,3,2,4,3)

  3. (2,2,4,4,3,3)

  4. Error

  5. Answer:

    (2,4,3,2,4,3)

    Solution not available.

Question: 3 -

What will be the output of below Python code?

tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)

Options:
  1. (5,1,7,6)

  2. Error

  3. (5,1,6,2)

  4. (5,1,7,6,2)

  5. Answer:

    Error

    Solution not available.

Question: 4 -

Choose the correct option.

Options:
  1. In Python, a tuple can contain only integers as its elements.

  2. In Python, a tuple can contain only strings as its elements.

  3. In Python, a tuple can contain both integers and strings as its elements.

  4. In Python, a tuple can contain either string or integer but not both at a time.

  5. Answer:

    In Python, a tuple can contain both integers and strings as its elements.

    Solution not available.

Question: 5 -

Which of the following creates a tuple?

Options:
  1. tuple1=(5)*2

  2. tuple1[2]=("a","b")

  3. None of the above

  4. tuple1=("a","b")

  5. Answer:

    tuple1=("a","b")

    Solution not available.