When to use tuple or dictionary in Python. Give some examples of programming situations mentioning their usefulness.
Answers
Answered by
4
Explanation:
List has mutable nature i.e., list can be changed or modified after its creation according to needs whereas tuple has immutable nature i.e., tuple can't be changed or modified after its creation. Also, you can't use a list as a key for a dictionary. This is because only immutable values can be hashed.
Answered by
2
★☆〖Qบęຮτ ı¨ ø nˇ〗☆★
⭐ The Usage of a:⭐
•List: When we need :
- A simple iterable collection of data, which may go for frequent modifications
•Tuple: When we need:
- No change in the data
•Set: When we need:
- The uniqueness of elements, or to avoid duplicacy
- No change in the data
•Dictionary: When:
- Our data are being constantly modified
- We need a fast look-up based on a custom key
- A logical association between the key-value pair
____________________________________________________
<Judge It Yourself...>
(Plagiarism-Free ☺️)
Hope it helps you! ヅ
✪ Be Brainly ✪
Similar questions
English,
4 months ago
Math,
4 months ago
India Languages,
9 months ago
India Languages,
9 months ago
Science,
1 year ago
Chemistry,
1 year ago