State some features of tuples.

Answer:

Some features of tuples are:

  • A tuple is a collection of Python objects much like a list. An object is anything that can be stored in a variable, such as numbers, strings, booleans, functions, classes, or modules.
  • A tuple is ordered, meaning that the elements have a defined order that will not change . The order of the elements is determined by the order in which they are placed in the tuple definition. For example, t = (1, 2, 3) has a different order than t = (3, 2, 1) .
  • A tuple is immutable , meaning that it cannot be changed after it is created. This means that you cannot add, remove, or modify elements in a tuple. If you want to change a tuple, you have to create a new one with the desired values. 

For example, t = (1, 2, 3) cannot be changed to t = (1, 2, 4) , but you can create a new tuple t = (1, 2, 4) and assign it to the same variable name.

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.