Python Programming - Tuples
Exercise : Tuples - General Questions
- Tuples - General Questions
16.
How can you find the index of the last occurrence of a specific element in a tuple?
Answer: Option
Explanation:
The
index()
method can be used with a negative start parameter to find the last occurrence of an element.
17.
What is the result of the expression
(1, 2, 3) * 2
?
Answer: Option
Explanation:
The '*' operator repeats the elements of the tuple.
18.
What is the primary difference between tuples and lists?
Answer: Option
Explanation:
Tuples cannot be modified once created, making them immutable.
19.
How do you create a tuple with the elements from 1 to 5?
Answer: Option
Explanation:
The
range()
function generates a sequence of numbers, and tuple()
converts it to a tuple.
20.
Which method is used to remove the first occurrence of a specific element in a tuple?
Answer: Option
Explanation:
The
remove()
method is used to remove the first occurrence of a specific element in a tuple.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers