Commerce

Tuples In Python MCQs

Practice Tuples In Python MCQs for competitive exams.

Tuples In Python MCQs

Practice questions from this topic.

Is the following Python code valid? >>> a=(1,2,3,4) >>> del a

  1. A. No because tuple is immutable
  2. B. Yes, first element in the tuple is deleted
  3. C. Yes, the entire tuple is deleted
  4. D. No, invalid syntax for del method
Report Error

What will be the output of the following Python code? >>> a=("Check")*3 >>> a

  1. A. ('Check','Check','Check')
  2. B. * Operator not valid for tuples
  3. C. ('CheckCheckCheck')
  4. D. Syntax error
Report Error

Is the following Python code valid? >>> a=(1,2,3) >>> b=('A','B','C') >>> c=tuple(zip(a,b))

  1. A. Yes, c will be ((1, 'A'), (2, 'B'), (3, 'C'))
  2. B. Yes, c will be ((1,2,3),('A','B','C'))
  3. C. No because tuples are immutable
  4. D. No because the syntax for zip function isn't valid
Report Error

What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:-1]

  1. A. (1, 2)
  2. B. (1, 2, 4)
  3. C. (2, 4)
  4. D. (2, 4, 3)
Report Error

What is the data type of (1)?

  1. A. Tuple
  2. B. Integer
  3. C. List
  4. D. Both tuple and integer
Report Error

What will be the output of the following Python code? >>>t1 = (1, 2, 4, 3) >>>t2 = (1, 2, 3, 4) >>>t1 < t2

  1. A. True
  2. B. False
  3. C. Error
  4. D. None
Report Error

What will the following code output: my_tuple = (1, 2, 3) new_tuple = my_tuple.copy() print(new_tuple)

  1. A. (1, 2, 3)
  2. B. (1, 2, 3, 1, 2, 3)
  3. C. (1, 1, 2, 2, 3, 3)
  4. D. (2, 1, 3)
Report Error

What is the output of the following code: my_tuple = (1, 2, 3) print(my_tuple[1])

  1. A. 1
  2. B. 2
  3. C. 3
  4. D. Error
Report Error

What is the purpose of the count() method for lists and tuples?

  1. A. Counts the occurrences of a specific element
  2. B. Adds the elements of one list or tuple to another
  3. C. Finds the index of a specific element
  4. D. Reverses the list or tuple
Report Error

What will be the output of the following code: my_tuple = (1, 2, 3) my_tuple[1] = 4 print(my_tuple)

  1. A. (1, 2, 3)
  2. B. (4, 2, 3)
  3. C. (1, 4, 3)
  4. D. None of these
Report Error

What is the purpose of the reverse() method for lists and tuples?

  1. A. Reverses the order of elements in the list or tuple
  2. B. Removes the last element
  3. C. Deletes the list or tuple
  4. D. Adds an element to the list or tuple
Report Error

In Python, how can you remove all occurrences of a specific element from a list or tuple?

  1. A. Use a loop and remove() method
  2. B. delete_all()
  3. C. clear()
  4. D. discard_all()
Report Error