wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

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

Open in App
Solution

Tuples are used to store the data which is not intended to change during the course of execution of the program. For example, if the name of months is needed in a program, then the same can be stored in the tuple as generally, the names will either be iterated for a loop or referenced sometimes during the execution of the program.

Dictionary is used to store associative data like student's roll no. and the student's name. Here, the roll no. will act as a key to find the corresponding student's name. The position of the data doesn’t matter as the data can easily be searched by using the corresponding key.

flag
Suggest Corrections
thumbs-up
5
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Computers in Accounting
ACCOUNTANCY
Watch in App
Join BYJU'S Learning Program
CrossIcon