What is Tuple in python?

 A tuple is a data structure used to store multiple values in a single variable, similar to a list.

Example: 

numbers = (10, 20, 30, 40)

names = ("Kavi","Arjun","Ashok")


Values are arranged by index number starting from 0. You can print a value based on its position / index.

names = ("kavi","arjun","akash")

print(names[0])

It will print the 0 index value of the names tuple.


Tuples are not changeable (immutable). Once a tuple is created, the values cannot be modified.

person_details = ("John", 25, "Europe")

You cannot update a value like we do in a list.


A tuple can also store different data types like List.

person_details = ("John", 25, 76.5, True)

Comments

Popular posts from this blog

What is Artificial Intelligence? What is Machine Learning? What is Data Science? how they are related to each other?

Linear Algebra - What is it?

What is a Python Library?