173,408 views
38 votes
38 votes
Choose the best collection for each situation.

You have a set of data that will not be changed and you will not need to add new items.


You wrote a loop to ask the user for a set of 100 numbers. You will add a number to the collection on each pass through the loop, then pass the collection to a function for processing.


You have the unique inventory number and description of every item in a store. You will need to add items when they come in and delete items when they are sold.

User Fred Basset
by
2.9k points

1 Answer

14 votes
14 votes

Answer:

first: tuple

second: list

third: dictionary

Step-by-step explanation:

first: tuple

tuples are immutable, so you can't add or remove items from a tuple

second: list

lists are mutable, so you can add and remove items from a list

third: dictionary

dictionaries are mutable, so you can add and remove items from a dictionary

User Brennanyoung
by
3.0k points