1.

What are the differences between list and tuple?

Answer»

In Python, both LIST and tuple are CLASSES of data structures. Differences between list and tuple are as follows.

List
Tuple
Lists are mutable i.e.; they can be modified
Tuples are immutable i.e.; they can’t be modified
Memory consumption of List is more
Memory consumption of Tuple is less as compared to List
List is more prone to errors and unexpected changes
Tuple is not prone to such errors and unexpected changes
It CONTAINS a lot of built-in methods
It doesn’t CONTAIN much built-in methods
Operations like insertion and deletion are performed better using list
Tuple is mainly used for accessing the elements
List has dynamic characteristics so it is slower compared to tuple
Tuple has STATIC characteristics so it is faster
Syntax: list_data1 = ['list', 'can', 'be', 'modified', 'easily']
Syntax: tuple_data1 = ('tuple', 'can’t', 'be', 'modified', 'ever')


Discussion

No Comment Found