Tuples in Python (1)
Tuples in Python (1)
PYTHON
CLASS - XII
INTRODUCTION
• 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