Wize Introduction to Programming Textbook > Values, Variables, and Types
Mutable vs Immutable
A student is choosing Python types for a small inventory program. Match each type to the description that correctly combines its contents with its mutability.
A.
Mutable collection associating keys with values that can be updated
B.
Mutable collection of distinct elements that supports adding and removing members
C.
Mutable ordered collection whose entries can be replaced by index
D.
Immutable sequence of characters whose individual positions cannot be overwritten
Dictionary
Set
String
List
A registration program stores confirmed participant numbers in a Python set. After this code executes, how many participant numbers remain in confirmed? Give an exact whole-number count, with no decimal places.
Python
confirmed = {14, 18, 23}
backup = confirmed
backup.add(18)
backup.add(27)
confirmed.remove(14)
backup = backup | {31, 35}
backup.remove(23)