Tuples in Python can be manipulated through various operations:
1. Tuples can be joined using the + operator if they contain compatible data types like other tuples or numbers. Some errors may occur if trying to join tuples with non-compatible types.
2. Tuples can be replicated using multiplication, sliced to extract subsets of elements, and compared using comparison operators.
3. Individual tuple elements cannot be deleted as tuples are immutable, but the del function can delete an entire tuple. Common tuple functions include len() to get length, max()/min() to find extremes, index() to find an element's position, and tuple() to convert other types to tuples.
Tuples in Python can be manipulated through various operations:
1. Tuples can be joined using the + operator if they contain compatible data types like other tuples or numbers. Some errors may occur if trying to join tuples with non-compatible types.
2. Tuples can be replicated using multiplication, sliced to extract subsets of elements, and compared using comparison operators.
3. Individual tuple elements cannot be deleted as tuples are immutable, but the del function can delete an entire tuple. Common tuple functions include len() to get length, max()/min() to find extremes, index() to find an element's position, and tuple() to convert other types to tuples.
Tuples in Python can be manipulated through various operations:
1. Tuples can be joined using the + operator if they contain compatible data types like other tuples or numbers. Some errors may occur if trying to join tuples with non-compatible types.
2. Tuples can be replicated using multiplication, sliced to extract subsets of elements, and compared using comparison operators.
3. Individual tuple elements cannot be deleted as tuples are immutable, but the del function can delete an entire tuple. Common tuple functions include len() to get length, max()/min() to find extremes, index() to find an element's position, and tuple() to convert other types to tuples.
Class -11 Python Revision Tour-II Based on CBSE Curriculum Class -12 Tuple Operations • Tuple joining • Both the tuples should be there to add with +.
Some errors in tuple joining-
• In Tuple + number • In Tuple + complex number • In Tuple + string • In Tuple + list • Tuple + (5) will also generate error because when adding a tuple with a single value, tuple will also be considered as a value and not a tuple..
• Tuple Replication- Tuple Slicing
Tuple will show till last element of list irrespective of upper
limit.
Every alternate element will be shown.
Every third element will be shown.
Tuple Comparision Tuple unpacking Tuple Deletion As we know that tuple is of immutable type, it is not possible to delete an individual element of a tuple. With del() function, it is possible to delete a complete tuple. Look at following example-
Error shown because
deletion of a single element is also possible.
Complete tuple has
been deleted. Now error shown on printing of tuple. Tuple Functions len( ) Function