Tuples in Python | Tuples Functions and methods in python
Hi guys in this blog we are going to discuss about Tuples in Python
The Tuples are depicted through parentheses i.e., round brackets, e.g., tuples in Python
- () #tuple with no member, empty tuple
- (7,) #tuple with one member(
- 1, 2, 3) #tuple of integers
- (1, 2.5, 3.7, 9) #tuple of numbers (integers and floating)
- (a, B, C)#tuple of characters
- (a, 1, b, 3.5, 'zero') #tuple of mixed value types
- (One, Two, Three') #tuple of string
Tuples are immutable sequences ie, you cannot change elements of a tuple in place.
Creating Tuples
To create a tuple, put a number of expressions, separated by commas in parentheses. That is create a tuple you can write in the form given below:T=()
T=(value, ...)
This construct is known as a tuple display construct.
Creating Empty Tuple
The empty tuple is (). You can also create an empty tuple
T= tuple()
Creating Single Element Tuple
Making a tuple with a single element is tricky because if you just give a single element in round brackets, Python considers it a value only, e.g.,
>>>t=(1)
Tuple Functions and Methods
- len()
- max()
- min()
- index()
- count ()
- tuple()