Python Programming - Tuples
Exercise : Tuples - General Questions
- Tuples - General Questions
31.
What is the purpose of the
tuple()
constructor?
Answer: Option
Explanation:
The
tuple()
constructor can be used for various purposes, including creating an empty tuple and converting other data types to tuples.
32.
What is the result of the expression
(1, 2, 3) + (4,)
?
Answer: Option
Explanation:
The '+' operator concatenates the two tuples.
33.
Which of the following methods is used to find the index of the last occurrence of a specific element in a tuple?
Answer: Option
Explanation:
The
index()
method with a negative start parameter can be used to find the last occurrence of an element.
34.
What is the output of the expression
max(('apple', 'orange', 'banana'))
?
Answer: Option
Explanation:
The
max()
function returns the largest element in the tuple based on lexicographic order.
35.
What is the result of the expression
tuple('hello')
?
Answer: Option
Explanation:
The
tuple()
constructor can convert a string to a tuple of its characters.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers