Skip to content

Latest commit

 

History

History
74 lines (64 loc) · 2.5 KB

File metadata and controls

74 lines (64 loc) · 2.5 KB

Programming in Python

Jupyter Notebook exercises for Python programming

Binder
Click “launch binder” above to launch the exercises in Binder, a read-only environment for Jupyter Notebooks. This means that your progress will be erased when the browser tab is closed. Please download the notebook files you wish to keep: right-click on the file and click "Download".

This programming guide for Python beginners is part of a guided lesson package for H2 Computing students, with a greater focus on programming methodology over Python feature coverage.

For exercises with a focus on learning Python features quickly, see Intro to Python.

The exercises are provided here, sans guidance.

Lessons

The following topics are covered:

Python fundamentals

  1. Introduction [X]
    • int, float, and arithmetic operators
    • bool and comparison operators
    • str, the concatenation and repetition operators
    • output
  2. Abstraction [X]
    • expressions and statements
    • constants
    • defining functions and parameters
    • functions vs procedures
    • variable scoping
  3. Selection [X]
    • input
    • if-elif-else
    • logical operators
  4. Recursion [X]
    • features of successful recursion
    • random functions for generating pseudorandom numbers
  5. Iteration [X]
    • Conditional iteration with while
    • Fixed iteration with for
    • slicing
  6. Data structures and mutability [X]
    • Sequences using list
    • Mappings using dict
    • list vs tuple vs str
    • mutable vs immutable objects
    • random functions for working with sequences
  7. Debugging [X]
    • trace tables and print() statements
    • the pdb debugger
  8. Identity [X]
    • Identity with the id() function
    • == vs is
  9. File IO: working with files and directories [X]
    • getting file handles from open()
    • file modes: read, write, and append
  10. Error handling with try [X]

Getting things done

  1. Handling CSV files with csv [X]
    • reader and writer for CSV without header
    • DictReader and DictWriter for CSV with header
  2. Convenience features [X]
    • f-strings
    • tuple unpacking
    • enumerate()
    • zip()
    • sorted()
    • reversed()
    • in-place operators
  3. Abstraction with modules [X]
    • importing modules
    • __name__
    • aliasing