Concatenation

Python allows us to join tuples using the concatenation operator depicted by symbol + .

Example:

[Class 11] Tuple Operations - Computer Science Tuples and Dictionaries - Concepts

Repetition

Repetition operation is depicted by the symbol *. It is used to repeat elements of a tuple. 

The repetition operator requires the first operand to be a tuple and the second operand to be an integer only.

Example:

part 2 - Tuple Operations - Concepts - Chapter 10 Class 11 - Tuples and Dictionaries - Computer Science - Class 11

Membership

In operator

The in operator checks if the element is present in the tuple and returns True , else it returns False.  

Example:

part 3 - Tuple Operations - Concepts - Chapter 10 Class 11 - Tuples and Dictionaries - Computer Science - Class 11

Not in operator

The not in operator returns True if the element is not present in the tuple, else it returns False.

Example:

part 4 - Tuple Operations - Concepts - Chapter 10 Class 11 - Tuples and Dictionaries - Computer Science - Class 11

Slicing

Tuple slicing creates a new tuple from an old one.

The slice operator allows you to specify where to begin slicing, where to stop slicing, and what step to take. 

Syntax:

tuple[Start : Stop : Stride]

Examples:

part 5 - Tuple Operations - Concepts - Chapter 10 Class 11 - Tuples and Dictionaries - Computer Science - Class 11

Remove Ads Share on WhatsApp
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo