This course provides a ramp-up to using Python for scientific and mathematical computing. Starting with the basics, it progresses to the most important Python modules for working with data, from arrays, to statistics, to plotting results. The material is geared towards scientists and engineers.

This is a hands-on programming class. All concepts are reinforced by informal practice during the lecture followed by lab exercises. Many labs build on earlier labs, which helps students retain the earlier material.

Applied Python is 35 percent hands-on, 65 percent lecture, with the longest lecture segments lasting for around 45 minutes. Students “learn by doing,” with immediate opportunities to apply the material they learn to real-world problems.

Course Duration: 5 days
Prerequisites:

While there are no programming prerequisites, programming experience is helpful. Students should be comfortable working with files and folders, and should not be afraid of the command line.

Hardware and Software Requirements:

The following should be installed on each student PC:

  • Python language (available from http://www.python.org)
  • Python libraries: numpy, scipy, matplotlib, PIL, iPython, pandas
  • An IDE or Python-aware editor (Spyder, Komodo Edit, Sublime, Eclipose, gVim, Notepad++, Emacs, etc.)
  • Any OS (Windows, Mac, Linux/Unix)
Course Objectives:
  • Create and run basic programs
  • Design and code modules and classes
  • Implement and run unit tests
  • Use benchmarks and profiling to speed up programs
  • Process XML and JSON
  • Manipulate arrays with numpy
  • Get a grasp of the diversity of subpackages that make up scipy
  • Use iPython notebooks for ad hoc calculations, plots, and what-if?
  • Manipulate images with PIL
  • Solve equations with sympy
Course Outline:
  • The Python Environment
    • About Python
    • Starting Python
    • Using the interpreter
    • Running a Python script
    • Python scripts on Unix/Windows
    • Using the Spyder editor

 

  • Getting Started
    • Using variables
    • Built-in functions
    • Strings
    • Numbers
    • Converting among types
    • Writing to the screen
    • String formatting
    • Command line parameters

 

  • Flow Control
    • About flow control
    • White space
    • Conditional expressions (if,else)
    • Relational and Boolean operators
    • While loops
    • Alternate loop exits

 

  • Sequences
    • About sequences
    • Lists and tuples
    • Indexing and slicing
    • Iterating through a sequence
    • Sequence functions,keywords, and operators
    • List comprehensions
    • Generator expressions
    • Nested sequences

 

  • Working with Files
    • File overview
    • Opening a text file
    • Reading a text file
    • Writing to a text file
    • Raw (binary) data

 

  • Dictionaries and Sets
    • Creating dictionaries
    • Iterating through a dictionary
    • Creating sets
    • Working with sets

 

  • Functions
    • Defining functions
    • Parameters
    • Variable scope
    • Returning values
    • Lambda functions

 

  • Errors and Exception Handling
    • Syntax errors
    • Exceptions
    • Using try/catch/else/finally
    • Handling multiple exceptions
    • Ignoring exceptions

 

  • OS Services
    • The OS module
    • Environment variables
    • Launching external commands
    • Walking directory trees
    • Paths, directories, and filenames
    • Working with file systems
    • Dates and times

 

  • Pythonic idioms
    • Small Pythonisms
    • Lambda functions
    • Packing and unpacking sequences
    • List Comprehensions
    • Generator Expressions

 

  • Modules and Packages
    • Initialization code
    • Namespaces
    • Executing modules as scripts
    • Documentation
    • Packages and name resolution
    • Naming conventions
    • Using imports

 

  • Classes
    • Defining classes
    • Constructors
    • Instance methods and data
    • Attributes
    • Inheritance
    • Multiple inheritance

 

  • Developer Tools
    • Analyzing programs with pylint
    • Creating and running unit tests
    • Debugging applications
    • Benchmarking code
    • Profiling applications

 

  • XML and JSON
    • Using ElementTree
    • Creating a new XML document
    • Parsing XML
    • Finding by tags and XPath
    • Parsing JSON into Python
    • Parsing Python into JSON

 

  • iPython
    • iPython basics
    • Terminal and GUI shells
    • Creating and using notebooks
    • Saving and loading notebooks
    • Ad hoc data visualization

 

  • numpy
    • numpy basics
    • Creating arrays
    • Indexing and slicing
    • Large number sets
    • Transforming data
    • Advanced tricks

 

  • scipy
    • What can scipy do?
    • Most useful functions
    • Curve fitting
    • Modeling
    • Data visualization
    • Statistics

 

  • A Tour of scipy Subpackages
    • Clustering
    • Physical and mathematical Constants
    • FFTs
    • Integral and differential solvers
    • Interpolation and smoothing
    • Input and Output
    • Linear Algebra
    • Image Processing
    • Distance Regression
    • Root-finding
    • Signal Processing
    • Sparse Matrices
    • Spatial data and algorithms
    • Statistical distributions and functions
    • C/C++ Integration

 

  • pandas
    • pandas overview
    • Dataframes
    • Reading and writing data
    • Data alignment and reshaping
    • Fancy indexing and slicing
    • Merging and joining data sets

 

  • matplotlib
    • Creating a basic plot
    • Commonly used plots
    • Ad hoc data visualization
    • Advanced usage
    • Exporting images

 

  • The Python Imaging Library (PIL)
    • PIL overview
    • Core image library
    • Image processing
    • Displaying images