Python (PyHacks) tutorials on lists, list comprehensions and Tuples has arrived

I have had many colleagues who work with the R programming language wanting something that is easily accessible for learning Python. I have started to compile some guides on how to work with Python data structures. My aim is to do a complete series of tutorials on how to utilise Python to its greatest potential.

I aim to do basic Python and then get on to some more intermediate Python very soon.

Everyone loves a list

Lists are the cornerstone of Python and something that everyone should be able to work with in Python. They take this form:

To make it easier to digest this information I have put together walkthrough YouTube tutorials to supplement the source code. These are divided into three separate videos, detailed in the subsections below.

List and List Operations 

These show you how to get started quickly and I discuss many different methods here:

Looping through lists and list comprehension

Here I look at using for loops to iterate through lists. Additionally, I show how to easily create list from lists using list comprehension. List comprehensions take the form:

Python List Comprehension - JournalDev

To break this down:

  • The expression goes first – this is the iterator element you want to perform an operation on. This could be as simple as casting all numbers to a specific type, or performing a calculation on the value
  • The next element is the iteration variable. This is the variable that will store the initial result through the iteration
  • The reference sequence is the list to loop over
  • The predicate (or conditional filter) is optional and can be used to reduce the list

Learn how:

Sorting, Grouping and Joining Lists

The last part of the list series focusses on Sorting, Grouping and Joining lists.

This is enough for the mutable (changeable structures). The next section is dedicated to Tuples.

What the heck is a Tuple?

Tuple is an immutable (unchangeable) collection of elements of different data types. It is an ordered collection, so it preserves the order of elements in which they were defined. Tuples are defined by enclosing elements in parentheses () , separated by a comma.

Source: https://blog.finxter.com/the-ultimate-guide-to-python-tuples/

To learn how to work with Tuples reference the below:

What’s next?

In the following weeks I aim to do videos on other Python subjects, such as:

  • Sets
  • Dictionaries
  • Functions, including Lambda function
  • Conditional expressions
  • Iteration
  • Iterators
  • Object Orientated Python

Where to get the code?

The code is available from the supporting GitHub.

Stay safe!

I would like you to keep following my posts and stay safe out there. I have a dream that I will get to 17 millions subscribers in a day, but perhaps I am deluded.

Top 30 Bottom Rik Mayall GIFs | Find the best GIF on Gfycat

Leave a Reply