Python Tuple Functions

Welcome to the tutorial of Python


In this tutorial we will be going through the functions of Tuples
Python Expression
Results
Description
len((1, 2, 3))
3
Length
(1, 2, 3) + (4, 5, 6)
(1, 2, 3, 4, 5, 6)
Concatenation
('Hi!',) * 4
('Hi!', 'Hi!', 'Hi!', 'Hi!')
Repetition
66 in (1, 2, 3)
False
Existence
for x in (4,5,6): print x,
4 5 6
Iteration


Python includes the following tuple functions −
Sr.No.
Function with Description
1
cmp(tuple1, tuple2)
Compares elements of both tuples.
2
len(tuple)
Gives the total length of the tuple.
3
max(tuple)
Returns item from the tuple with max value.
4
min(tuple)
Returns item from the tuple with min value.
5
tuple(seq)
Converts a list into tuple.


Python Tuple Functions Python Tuple Functions Reviewed by Analytics Pundit on November 29, 2019 Rating: 5

No comments:

Theme images by lishenjun. Powered by Blogger.