python tuple function

We perform many operations in tuple as in list. Lot of python tuple function working on list is at tuple. A function applies on construct and return the result. But it is not possible to modify elements in tuple hence the functions used for modification are not applicable in tuple.
Functions operating in the tuple are as, append(),insert(),remove(),pop(),clear(),extend(),len(),max(),min(),sum(),any(),all(),sorted(),tuple().

Python tuple Functions syntax

  1. Len():-

my_tuple
(1,2,3)
len my_tuple
O/p:-
      3
b. max():-
It returns the item from the tuple with the highest value.
We cannot apply this function on the tuple my_tuple, because it cannot be compared to a list.
e.g:-
a= (1.2, 4, 5)
max (a)
O/p:-
5
c.min ():-
Like the min () function, the min () will returns the item with the lowest value.
e.g:-
a= (1.2, 4, 5)
min(a)
O/p:-
1
d.sum ():-
This function returns the arithmetic sum of all items in the tuple.
a= (1.2, 4, 5)
sum(a)
O/p:-
12
e. sorted():-
The function returns a sorted version of the tuple so sorting is in ascending order, and it doesn’t modify the original tuple in Python.
e.g:-
           a= (1.2, 4, 5)
sorted (a)
O/p:-
[1,2,3,5]

Additional Services : Refurbished Laptops Sales, Python Classes, Share Market Classes And SEO Freelancer in Pune, India