tuples 8
tuples 8
tuples 8
Introduction
• In Python, tuple is also a kind of container which can store list
of any kind of values.
• Long tuple:
• Nested tuple:
Creation of Tuple
tuple() function is used to create a tuple from other sequences.
See examples-
Tuple creation from string Tuple creation from list
• Membership operator:
• Working of membership operator “in” and “not in” is same as
in a list. (for details see the chapter- list manipulation).
• Concatenation and Replication operators:
• + operator adds second tuple at the end of first tuple. * operator repeats
elements of tuple.
Accessing a Tuple
• Accessing Individual elements-
• Traversal of a Tuple –
for <item> in <tuple>:
#to process every element.
OUTPUT
Tuple Operations
• Tuple joining
• Both the tuples should be there to add
with +.
• Tuple Replication-
Tuple Slicing
max( ) Function
min( ) Function
index( ) Function
tuple( ) Function