From the course: Python Data Structures: Dictionaries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dictionary vs. sets and tuples

Dictionary vs. sets and tuples - Python Tutorial

From the course: Python Data Structures: Dictionaries

Start my 1-month free trial

Dictionary vs. sets and tuples

- [Instructor] Welcome to the continuation of comparison of dictionary with other data structures in Python. The two data structures that I'm going to compare in this video are dictionary against tuples and sets. A tuple is a collection which is ordered and unchangeable and is indexed, allows duplicate members. A set is a collection which is unordered and unindexed, no duplicate members. A dictionary is a collection which is unordered, changeable, and indexed, no duplicate keys. Dictionaries, lists, and tuples give better control in accessing the data. Dictionaries and sets have very fast access times compared to lists and tuples. So let's take a look at this program here. We have tuples in line three which is called cities, a collection of names of cities, enclosed in parentheses and separated by commas. Line four, print cities square bracket zero, gives the first element. However, just like in dictionaries and lists,…

Contents