Python

Introduction to Tuples in Python | Python Tutorials

Introduction to Tuples in Python | Python Tutorials

What are Tuples?

Tuples are defined as an immutable collection of objects and cannot be changed, unlike lists. Tuples use parenthesis.

Code Example

tuples = ('earth', 'water','air','fire');
tuples2 = (500,800,600,700,650,850 );
print "tuples[1]: ", tuples[1];
print "tuples2[1:4]: ", tuples2[1:4];

Code Example 2

tuple_start = ()
print(tuple_start)

tuple_start = (600,400,800)
print(tuple_start)

tuple_start = ("Start",500,14)
print(tuple_start)

Rajib Kumar Jha

Rajib Kumar Jha is a certified Big Data Architect, is a Computer Science student at Chandigarh University.