- Tuple
- Tuple Operations
- Tuple Functions
- Tuple to List and vice versa
1.Tuples
A tuple is created by placing all the items (elements) inside parentheses (), separated by commas. The parentheses are optional, however, it is a good practice to use them.
A tuple can have any number of items and they may be of different types (integer, float, list, string, etc.).
- Immutable Python objects
- Sequences
- Similar to List
- Tuples cannot be changed unlike lists
- (.,.,.,.)
2.Tuples Operations
- Accessing
- Indexing
- Slicing
- Matrixes
- T = ( T0_1, T1_2, .. ,Tm_n )
- T[x/-x]
- T[x/:y/]
- T_x+T_y – Concatenation
- T[x]*n – Repetition
- c in T – Membership
3.Tuple Functions
In Python, a tuple is an immutable sequence type. One of the ways of creating tuple is by using the tuple() construct.
- len(T) : no_ele_T
- max(T) : Lar_T
- min(T) : Sml_T
- tuple(s) : s → T
4.Tuple to List and vice versa
- list(T) : L[.,.] ←T(.,.)
- tuple(L) : T(.,.) ←L[.,.]