Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What is Tuple in python? | Python Tuple Tutorial | Edureka

501 views

Published on

YouTube Link: https://youtu.be/GstQPTWpt88
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka video on 'Tuple In Python' will help you understand how we can use Tuple in Python with various examples for better understanding. Following are the topics discussed:

What Is Tuple In Python?
Accessing Elements In A Tuple
Changing A Tuple
Concatenating Two Tuples
Deleting A Tuple
Tuple Methods
List vs Tuple
Tuple Constructor
Other Examples

Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in

Published in: Technology
  • Be the first to comment

What is Tuple in python? | Python Tuple Tutorial | Edureka

  1. 1. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
  2. 2. What Is Tuple In Python? Accessing Elements In A Tuple Changing A Tuple www.edureka.co/python Concatenating Two Tuples Deleting A Tuple Tuple Methods List vs Tuple Tuple Constructor Other Examples
  3. 3. www.edureka.co/python
  4. 4. www.edureka.co/python A tuple is an immutable data type in python, almost similar to a list in python in terms of indexing and having duplicate members. It is a collection data type that stores python objects separated by commas.
  5. 5. www.edureka.co/python
  6. 6. Accessing Elements In A Tuple www.edureka.co/python • A web-crawler is also known as a web spider, automatic indexer or simply crawler. • It is an internet bot that helps in web indexing • Web crawlers helps in collecting information from a webpage and the links related to them • It also helps in validating HTML code and hyperlinks. • They crawl one page at a time until all the pages are indexed. Indexing It is a data structure technique to effectively retrieve information from a data structure. In python, several data types support indexing Slicing is a technique in which we use the slicing operator ‘:’ to get a range of elements from a tuple or any other data type that supports indexing for accessing elements.
  7. 7. www.edureka.co/python
  8. 8. Changing A Tuple www.edureka.co/python To install scrapy, simply run the following command in the command prompt or in the terminal, or simply you can add the package from the project interpreter too.Even though tuples in python are immutable in nature, a nested object in a tuple can be changed. Or in general, a tuple in python can be reassigned with a different value.
  9. 9. www.edureka.co/python
  10. 10. Joining two tuples is a very easy task. You just to assign the addition of the two tuples to another variable and it will return the concatenated tuple with the values of both the tuples Concatenating Two Tuples www.edureka.co/python
  11. 11. www.edureka.co/python
  12. 12. Deleting A Tuple www.edureka.co/python Being an immutable data type, a tuple in python does not allow any changes and you cannot even remove an element from a tuple after the declaration. But there is a keyword ‘del’ which will delete the tuple altogether.
  13. 13. www.edureka.co/python
  14. 14. Tuple Methods www.edureka.co/python • Returns the count of the elementCount • Returns the index number of the element Index
  15. 15. www.edureka.co/python
  16. 16. List vs Tuple www.edureka.co/python •Used for homogenous data types •Mutable in nature •Does not have immutable elements •No guarantee that the data is write-protected •Generally used for heterogeneous data types •Immutable in nature, which helps in faster iteration •Immutable elements can be used as a key for a dictionary •Implementing a tuple with data that does not change guarantees that it is write-protected
  17. 17. www.edureka.co/python
  18. 18. Tuple Constructor www.edureka.co/python • It is possible to create a tuple using a tuple() constructor as well. We can even use the tuple constructor to change a list to a tuple.
  19. 19. www.edureka.co/python
  20. 20. Other Examples www.edureka.co/python Iterating Through A tuple Membership Test On A Tuple
  21. 21. www.edureka.co/python

×