Python Zero to Heros

Online Absolute Beginner Python Tutorials 

Every Sunday 2pm (UK time/ BST)

Get this slide deck:


Beginner topics:

Python objects, Control flows,

Functions, modeuls, classes and decorators

strings operations and regex with re


pytest with fixtures and mock

property-based testing

python linters & auto-formatters

TDD, type hinting

Intermedite topics:

Iterators, generators, async


generating docs, pypi

Functional Programming

List (revisit)


  • mutable - can change the elements
  • hence not hashable (what does that mean)
  • A non-mutable, hashable cusion is Tuple - e.g (1, 2)
  • str is also a sequence that is hashable
  • list object elements are by reference so changes will populate

List (revisit)


  • sequencial object
  • has __getitem__()
  • iterable
  • ordered (can be sorted)

List comprehension


A short cut to create a list in a "Pythonic way"

h_letters = []

for letter in 'human':
h_letters = [ letter for letter in 'human' ]

Sorting Dicts


  • Dictionaries on the other hands are not ordered
  • We cannot sort a dicitonary
  • But we can have a ordered dictionary form the collections module

from collections import OrderedDict
d = {'banana': 3,
     'pear': 1,
     'orange': 2}
new_d = OrderedDict(sorted(d.items()))
c = Counter()
c = Counter('gallahad')
c = Counter({'red': 4, 'blue': 2})
c = Counter(cats=4, dogs=8)

Next week:

Sunday 2pm (UK time/ BST)

There are also Mid Meet Py every Wednesday 1pm

More Python List and Dict

By Cheuk Ting Ho

More Python List and Dict

  • 1,238