Python Tuple - Introduction

Overview:

One might wonder what this name tuple is. If we look at the etymology of the name tuple, it is a generalisation to denote any sequence of single, double, triple, quadruple, quintuplesextuple, septuple, octuple, ..., n‑tuple entries.

In Python a tuple is a collection. A container to hold a collection of elements. A tuple is a collection that can not be modified. A tuple is an immutable object. The entries a tuple can have can be of heterogeneous types. By design, whenever a collection that can not be modified is needed in a program tuples can be used.

Example,
PrimaryColors = (Red,Green,Blue);

 

Inserts and Deletes are not allowed in a tuple

tuple

Two tuples with different ordering of its elements are not equal

Tuple Construction using Parentheses

Access a value in a tuple using subscript notation
Create a slice of a tuple
Create a slice of a tuple with a step parameter

len(tuple_in)
min(tuple_in)
max(tuple_in)

Concatenation of two tuples


Copyright 2024 © pythontic.com