English

What advantages do tuples have over lists?

Advertisements
Advertisements

Question

What advantages do tuples have over lists?

Short/Brief Note
Advertisements

Solution

The advantages of tuples over the lists are as follows:

  1. Tuples are faster than lists.
  2. Tuples make the code safe from any accidental modification. If data is needed in a program that is not supposed to be changed, then it is better to put it in ‘tuples’ than in ‘list’.
  3. Tuples can be used as dictionary keys if it contains immutable values like strings, numbers, or other tuples. ‘Lists’ can never be used as dictionary keys as ‘lists’ are mutable.
shaalaa.com
Concepts of Tuples in Python
  Is there an error in this question or solution?
Chapter 10: Tuples and Dictionaries - Exercise [Page 224]

APPEARS IN

NCERT Computer Science [English] Class 11
Chapter 10 Tuples and Dictionaries
Exercise | Q 5. | Page 224
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×