Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tuple.

Similar presentations


Presentation on theme: "Tuple."— Presentation transcript:

1 Tuple

2 A Tuple is a collection of Python objects separated by commas
A Tuple is a collection of Python objects separated by commas. In some ways a tuple is similar to a list in terms of indexing, nested objects and repetition but a tuple is immutable unlike lists which are mutable. Tuple

3 Creating tuple Tuple can be created by using (),
Example: Tuple Name=("a", "b") From now we will using t for tuple name Or using tuple constructor,       Example: t=tuple(("a", "b"))       Note the double round brackets First is for tuple function      and second is a iterable having elements to add in the list. Creating tuple

4 Tuple uses indexing to store elements so we can access items using indexes,
Example: t[Index Number] This will return element on that index. We can print this and can also take it into a variable. Can also access all elements using for loop, Example: for i in t: print(i) Accessing tuple

5 Tuple functions Method Description count()
Returns the number of times a specified value occurs in a tuple index() Searches the tuple for a specified value and returns the position of where it was found Tuple functions

6 Made by Tanmay mudgal


Download ppt "Tuple."

Similar presentations


Ads by Google