PCEP-30-02 · Question #346
What is true about tuples? (Choose two.)
The correct answer is A. Tuples can be concatenated using the + operator. Tuples support concatenation with + just like strings and lists - (1, 2) + (3, 4) produces (1, 2, 3, 4) - making A correct. B is also correct (and likely the intended second answer): an empty tuple can be written as tuple() in addition to (), so the answer key listing only A…
Question
Options
- ATuples can be concatenated using the + operator
- BAn empty tuple can be written as tuple ().
- CEach element of a tuple must be unique.
- DIf tup is a non-zero-length tuple, del tup[0] will delete its first element.
How the community answered
(59 responses)- A83% (49)
- B3% (2)
- C5% (3)
- D8% (5)
Explanation
Tuples support concatenation with + just like strings and lists - (1, 2) + (3, 4) produces (1, 2, 3, 4) - making A correct. B is also correct (and likely the intended second answer): an empty tuple can be written as tuple() in addition to (), so the answer key listing only A appears incomplete.
Why C is wrong: tuples place no uniqueness constraint on their elements - (1, 1, 2) is perfectly valid. Uniqueness is a property of sets, not tuples.
Why D is wrong: tuples are immutable, so del tup[0] raises a TypeError. You cannot add, remove, or modify individual elements after creation.
Memory tip: Think of a tuple as a "frozen list." Everything a list can do non-destructively (concatenate, slice, index) a tuple can do too - but anything that would change the sequence (delete, append, assign) is off-limits.
Community Discussion
No community discussion yet for this question.