Key Points

Python Basics Recap


  • Assign values to variables using =
  • Generate lists using square brackets []
  • Use indexes inside [], starting at 0, to select characters from strings and items from lists
  • Use for to loop through items in iterable objects
  • Make conditional expressions using ==, !=, >, <, >= and <=
  • Use f'{}' to embed formatted variables inside strings
  • Avoid use of generative AI for this course

Dictionaries


  • JSON is a simple, easy to interpret format for unstructured data
  • Dictionaries are defined using key:value pairs
  • Dictionaries can be nested, and mixed with lists
  • Web API’s can be accessed using the requests library

Defensive Programming


  • try-except structures are useful for catching errors as they occur
  • assert structures are useful for forcing errors early, to avoid wasted effort

Software Package Management


  • conda virtual environments are useful for installing programs with differing requirements
  • conda config --add channels <channel> adds a new channel to your list of sources
  • conda search <package> will find all available versions of a package in your list of sources
  • conda create -n <env> <package(s)> can be used to create a virtual environment from a list of packages
  • conda install -n <env> <pacakge(s)> installs packages in a pre-existing environment
  • conda activate <env> activates the named environment, giving access to the software installed there
  • conda deactivate deactivates the current environment
  • conda export --from-history > <file.yml> creates a portable record of your current environment
  • conda env create --file <file.yml> <env> creates a new environment from an environment file

Object oriented programming and classes in Python


  • OOP
  • Classes

Structuring a Python project


  • Projects
  • IDEs

Testing in Python


  • assert
  • testing frameworks