Python Tuples

In this page you learn about of python tuples are easy and most simple to implement in Python.A tuple is a grouping of unchanging articles, consequently tuple can't be changed. The items are encased inside of bracket and isolated by comma. Tuple is like rundown. Just the distinction is that rundown is encased between square section, tuple in the middle of bracket and List have variable articles while Tuple have permanent items.

Tuple Operations

Different Operations can be performed on Tuple. Operations performed on Tuple are given as:

  • Adding Tuple: Tuple can be included by utilizing the linking operator (+) to join two tuples.
  • Replicating Tuple: Recreating means rehashing. It can be performed by utilizing "*" administrator by a particular number of time.
  • Tuple slicing: A subpart of a tuple can be recovered on the premise of record. This subpart is known as tuple slice.

Functions of Tuple:

There are following in-built Type Functions:

Function Description
min(tuple) Returns the minimum value from a tuple.
max(tuple) Returns the maximum value from the tuple.
len(tuple) Gives the length of a tuple
cmp(tuple1,tuple2) Compares the two Tuples.
tuple(sequence) Converts the sequence into tuple.

Why Use Tuple?

  1. Processing of Tuples are faster than Lists.
  2. It makes the data safe as Tuples are immutable and hence cannot be changed.
  3. Tuples are used for String formatting.