Computer Science, asked by ashutosh1240, 9 months ago

When to use tuple or dictionary in Python. Give some examples of programming situations mentioning their usefulness.

Answers

Answered by anushka177561
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 MrEccentric
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