Python Bootcamp

This series of workshops consists of six sessions, totaling about 20 hours of instruction and exercises. The content is appropriate for students with some experience handling python code in the classroom, but also covers material that could be quite useful to typical scientists who use python for data analysis. Each session comes with a lecture component, the average length of which is approximately 90 minutes. Each session also comes with a series of practice exercises, which are intended to take an additional 90 - 120 minutes. Recordings of each lecture component are provided below, along with notes on the key topics covered and links to the slides and exercises.

I constructed this bootcamp myself, but others are welcome to contribute additional content. The curriculum has grown somewhat since it was first introduced, most notably in the number of available practice exercises. The first instance was held virtually in May 2020 at the beginning of the Summer Undergraduate Research Program in the Department of Astronomy at The Ohio State University. After I graduated from Ohio State, a team of my classmates took over the instruction. To this day, it remains a graduate student-led scientific computing workshop. I have also run a subset of these exercises for the CASSI summer research interns at Carnegie Observatories.

These workshops are first and foremost for the scientific community and our students. Sharpening our programming skills makes us more efficient as researchers. For that reason, these resources are free to use for everyone.

Introduction

Curriculum

Basics of the Unix Terminal
  • Simple Commands
  • Aliases
  • Environment Variables
  • PATH and PYTHONPATH
Python as a Programming Language
  • Compiled versus Interpreted Code
  • Static versus Dynamic Typing
  • Weak versus Strong Typing
  • Objects and the Python Data Model

Fundamentals

Curriculum

The Basics of Python and Syntax Review
  • Built-in types: int, float, list, tuple, dict
  • The list versus the NumPy array
  • Conditionals: if, elif, and else
  • Loops: for and while
  • Functions: def
  • Simple file I/O with and without NumPy
  • Catching exceptions: try, except, and finally
  • Built-in iteration tools: any, all, zip, map, and filter

Packages

Curriculum

Documentation in Python
  • reStructuredText
  • Standard format and contents
Anaconda
  • NumPy, SciPy, and Matplotlib
  • Example plotting script line-by-line with documentation
Multi-File Python Programs
  • Importing code in the same directory
  • The __init__.py file
  • The usefulness of your PYTHONPATH

Object-Oriented Programming 1

Curriculum

Object-Oriented Programming
  • Properties and setter function
  • Class methods and static methods
  • Syntactic sugar
  • Emulating numeric types

Object-Oriented Programming 2

Curriculum

Object-Oriented Programming
  • Inheritance
  • Composition

Basic Software Engineering

Curriculum

Object-Oriented Programming
  • Multiple Inheritance
Basic Principles of Software Engineering
  • DRY: Don't Repeat Yourself
  • No ifs, ands, or buts
  • Version control