Python Programming - Tuples

Exercise : Tuples - General Questions
  • Tuples - General Questions
1.
What is the key characteristic of a tuple?
Mutable
Ordered
Dynamic
Indexed
Answer: Option
Explanation:
Tuples in Python are ordered collections, meaning the order of elements is maintained.

2.
How do you create an empty tuple?
empty_tuple = ()
empty_tuple = [ ]
empty_tuple = new Tuple()
empty_tuple = {}
Answer: Option
Explanation:
An empty tuple can be created using parentheses with no elements.

3.
Which of the following statements about tuples is true?
Tuples can be resized after creation.
Tuples do not allow duplicate elements.
Elements of a tuple cannot be accessed by index.
Tuples can contain a mix of data types.
Answer: Option
Explanation:
Tuples in Python can contain elements of different data types.

4.
What happens when you try to modify a tuple?
Raises a TypeError
Automatically converts it to a list.
Adds the new element to the end of the tuple.
Modifies the element at the specified index.
Answer: Option
Explanation:
Tuples are immutable in Python, and attempting to modify them raises a TypeError.

5.
What is the purpose of the tuple.count() method?
Counts the number of elements in the tuple.
Counts the occurrences of a specific element in the tuple.
Returns the index of the first occurrence of a specific element.
Checks if a specific element exists in the tuple.
Answer: Option
Explanation:
The count() method in Python tuples is used to count the occurrences of a specific element.