Python Programming 1 (PYP1) – Outline

Detailed Course Outline

Day 1

Course Introduction

  • Administration and Course Materials
  • Course Structure and Agenda
  • Delegate and Trainer Introductions

Session 1: GETTING STARTED

  • About Python
  • Python versions
  • Python documentation
  • Python runtimes
  • Installing Python
  • The REPL shell
  • Python editors

Session 2: PYTHON SCRIPTS & SYNTAX

  • Script naming
  • Comments
  • Docstring
  • Statements
  • The backslash
  • Code blocks
  • Whitespace
  • Console IO (to enable the writing of simple programs)
  • A first Python program
  • Script execution

Session 3: VARIABLES & DATA TYPES

  • Literals
  • Identifiers
  • Assignment
  • Numbers (bool, int, float, complex)
  • Binary, octal, and hexadecimal numbers
  • Collections (str, list, tuple, set, dict)
  • None
  • Implicit and explicit type conversion (casting)
  • The type function

Session 4: OPERATORS & EXPRESSIONS

  • Arithmetic Operators
  • Assignment Operators
  • Comparison Operators
  • Logical Operators
  • Membership Operators
  • Bitwise Operators
  • Identity Operators

Session 5: CONDITIONS & LOOPS

  • Conditional statements (if, elif, else)
  • Short hand if/if else
  • Python's alternative to the ternary operator
  • Iterative statements (while, for, else)
  • The range function
  • Iterating over a list
  • Break
  • Continue
  • Nested conditional/iterative statements

Day 2

Session 6: FUNCTIONS

  • Declaration
  • Invocation
  • Default values for parameters
  • Named arguments
  • args and kwargs
  • Returning multiple values
  • Nested functions
  • Functions as data
  • Introduction to lambda expressions
  • Variable scope
  • The pass keyword

Session 7: OBJECTS AND CLASSES

  • About objects
  • Attributes and the dot notation
  • The dir function
  • Dunder attributes
  • Mutability
  • The id function
  • Pass by reference
  • Introduction to Classes
  • Class Declaration and Instantiation
  • Data attributes
  • Methods
  • Composition

Session 8: LISTS

  • About lists
  • List syntax including slicing
  • Getting and setting list elements
  • Iterating over a list
  • Checking for the presence of a value
  • The len function
  • List methods incl. append, insert, remove, pop, clear, copy, sort, reverse etc.
  • The del keyword
  • Appending to and combining lists
  • List comprehension

Session 9: TUPLES

  • About tuples
  • Tuple syntax
  • Getting tuple elements including unpacking
  • Iterating over a tuple
  • Checking for the presence of a value
  • The len function
  • Appending to and combining tuples

Session 10: SETS

  • About Sets
  • Dictionary syntax
  • Creating, adding and removing set elements
  • Iterating over a set
  • Membership Testing
  • Sorting
  • Copying
  • Set methods incl. union, intersection, difference, symmetric_difference etc.

Day 3

Session 11: DICTIONARIES

  • About dictionaries
  • Dictionary syntax
  • Getting and setting dictionary elements
  • Iterating over a dictionary (keys, values, and items)
  • Checking for the presence of a key
  • The len function
  • Dictionary methods incl. keys, values, items, get, pop, popitem, clear etc.
  • The del keyword
  • Dictionary comprehension

Session 12: STRINGS

  • About strings
  • String syntax including slicing
  • Escape characters
  • Triple-quoted strings
  • Concatenation
  • Placeholders
  • The format method
  • Other methods e.g. endswith, find, join, lower, replace, split, startswith, strip, upper etc.
  • A string as a list of bytes

Session 13: MODULES & PACKAGES

  • About modules
  • The module search path
  • Importing modules
  • Namespaces
  • Importing module objects
  • The import wildcard
  • Aliases
  • Importing within a function
  • Executable modules
  • Reloading a module
  • About packages
  • Importing packaged modules
  • Importing packaged module objects
  • Package initialisation
  • Subpackages
  • Referencing objects in sibling packages
  • The Standard Library
  • Installing modules and packages using pip

Session 14: PATTERN MATCHING

  • About regular expressions
  • Regular expression special characters
  • Raw strings
  • About the re module
  • re module functions incl. match, search, findall, full match, split, sub

Day 4

Session 15: DATES

  • About the datetime module
  • datetime object attributes
  • Creating a datetime object
  • Date arithmetic
  • Formatting dates

Session 16: EXCEPTION HANDLING

  • About exceptions and exception handling
  • Handling exceptions (try, except, else, finally)
  • Exception types
  • The exception object
  • Raising exceptions
  • Custom exception types

Session 17: FILES & THE FILESYSTEM

  • The open function
  • Methods for seeking (seekable, seek)
  • Methods for reading from a file (readable, read, readline, readlines)
  • Iterating over a file
  • Methods for writing to a file (writable, write, writelines)
  • Introduction to context managers
  • File parsing for files of type CSV, XML, JSON, YAML
  • About the os module
  • os module functions incl. getcwd, listdir, mkdir, chdir, remove, rmdir etc.
  • Session 18: DATABASES
  • The DB-API
  • DP-API implementations
  • Establishing a connection
  • Creating a cursor
  • Executing a query
  • Fetching results
  • Transactions
  • Inserting, updating, and deleting records