Python Programming - Tuples
Exercise : Tuples - General Questions
- Tuples - General Questions
21.
What is the correct way to access the second element of a tuple?
Answer: Option
Explanation:
In Python, indexing starts from 0, so the second element can be accessed using index 1.
22.
What does the
sorted()
function return when applied to a tuple?
Answer: Option
Explanation:
The
sorted()
function returns a sorted list, even when applied to a tuple.
23.
How do you create a tuple with repeated elements?
Answer: Option
Explanation:
Repeating elements can be done directly within the tuple.
24.
Which of the following methods is used to find the total number of occurrences of a specific element in a tuple?
Answer: Option
Explanation:
The
count()
method is used to find the total number of occurrences of a specific element in a tuple.
25.
What is the result of the expression
len(('apple', 'orange', 'banana'))
?
Answer: Option
Explanation:
The
len()
function returns the number of elements in the tuple, and in this case, there are three elements.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers