Fundamental building blocks in Python – Sets, Lists, Dictionaries and Tuples

This article was first published on Python – Hutsons-hacks , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

I have been working hard to compile a whole set of videos that help you to understand the core data structures that underpin the really powerful Python programming language.

Tuples

For tuples, you can view the code here, on GitHub. I would recommend you watch the video, pull the code linked here and code along.

Essentially, tuples are immutable, meaning that once you have created the tuple in memory, you cannot change the tuple. This is the massive difference between a tuple and a list. One cannot be changed (tuple) and one can be changed (lists) after creation.

Find out more:

Lists

The most widely used data structure in Python. I use them every second of the day, as I like the ability to change the list once I have initialised it.

Lists support methods for popping (removing an item), updating, appending, removing and many more methods.

To GitHub code for the below tutorial:

Dictionaries

Dictionaries are different, as they are stored in key and value pairs. These are the data structures that underpin data frames in the Pandas library.

The Github code for the below tutorial:

Sets

A set is a collection which is unorderedunchangeable, and unindexed. These are similar to tuples in their immutability, but different in the fact that they are not ordered and not indexed.

The GitHub code for the below tutorial:

What’s next?

Feel free to delve into the PyHacks tutorials repo, as I have many more tutorials I have been creating on using the awesome Python language.

These tutorials ease you in to Python and provide the starting building blocks on your Python journey. Think of these tutorials as a Python birthday cake from me to you:

The only way to satisfy a programmer on his birthday! : r/Python
To leave a comment for the author, please follow the link and comment on their blog: Python – Hutsons-hacks .

Want to share your content on python-bloggers? click here.