Python Programming - Tuples
Exercise : Tuples - General Questions
- Tuples - General Questions
26.
How can you create a shallow copy of a tuple?
Answer: Option
Explanation:
The slicing technique [:] creates a shallow copy of the tuple.
27.
Which method is used to remove all occurrences of a specific element from a tuple?
Answer: Option
Explanation:
Assigning the result of
replace()
with an empty tuple removes all occurrences of the specified element.
28.
What is the output of the expression
min(('apple', 'orange', 'banana'))
?
Answer: Option
Explanation:
The
min()
function returns the smallest element in the tuple based on lexicographic order.
29.
Which of the following statements about tuples in Python is correct?
Answer: Option
Explanation:
Tuples in Python are immutable, meaning their size and elements cannot be changed after creation.
30.
How do you unpack the elements of a tuple into separate variables?
Answer: Option
Explanation:
Using the unpacking syntax, you can assign the elements of a tuple to separate variables.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers