11-TUPLE
11-TUPLE
• STRINGS
• LISTS
• TUPLE
Introduction
• In Python, tuple is also a kind of container which can store list of
any kind of values.
• Long tuple:
• Nested tuple:
Creation
TUPLE of Tuple
CREATION
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 –
ACCESSING Tuple
TUPLE
• Accessing Individual elements-
• Traversal of a Tuple –
for <item> in <tuple>:
#to process every element.
OUTPU
T
TUPLE OPERATION
Tuple Operations
• Tuple joining
• Both the tuples should be there to add
with +.
• Tuple Replication-
ACCESSING – TUPLE
Tuple Slicing
max( ) Function
min( ) Function
index( ) Function
tuple( ) Function
STRING LIST TUPLE DICTIONARY