Python Tuple - Introduction

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, quintuple, 
sextuple, 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. That is, a tuple is an immutable collection.
A constant collection. The entries a tuple can have can be of heterogeneous types.
By design whenever a constant collection is warranted in a program these 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 2023 © pythontic.com