Useful resources for python programming and debugging; these can be used for any programming assignments or the final project.

Google Sheet Resources: (HW1 only)

Python Resources:

We will be using Python3. Useful Pieces of the Python Standard Library (v3.7):

Earlier versions of this course allowed for students to use Python2 or Python3 on their machines.

  • Python2 or Python3?
    • Short Answer: Python2.7 is often still used for research because many Python modules are written in Python version 2. Python 3 is quickly becoming the standard version, and many packages now offer python3 distributions.
    • Here's a great tutorial with examples explaining the differences between Python 2 and Python 3.
    • Python2 and python3 are both available on the Macs in the ETC labs. Type python or python3 and double check the version. Type quit() to exit the interpreter.
  • Instructions for installing Python on your personal machine.
    • If you are using a Mac, python is probably already installed. You can update it to the latest version using this tutorial.
    • If you are using a PC, Python is probably not yet installed. On the Python for Windows page, download the appropriate windows installation.
  • Forgot some syntax? Have a bug?
    • Make sure your Python Path is set correctly. See instructions below
    • Double check your syntax with the Python Cheat Sheet.
    • The online Python Tutor visualizes Python code and shows the memory tables (called "data frames") in an interactive, step-by-step fashion.
    • This PDF slide deck from Bio131 covers most of the typical python concepts we will use.
    • Useful Tabs to Spaces converter.
  • Useful Pieces of the Python Standard Library [python2] [python3]
  • Setting your Python Path. How does Python know where random.py is? What about one of the files your provide, such as graphspace_utils.py? When importing a module,
    1. Python first looks in the current directory. If graphspace_utils.py is there, so it can be imported.
    2. If the module (e.g., random.py) is not in the current directory, then it will look in a list of previously-determined directory locations.
    3. If the module is not in the list of locations, then Python will throw an error.
    This list of previously-determined directory locations is specified in your $PYTHONPATH environment variable. If you have a directory that contains frequently-used modules (e.g., the directory containing the *_utils.py scripts), you can add this directory to the $PYTHONPATH variable. Instructions depend on your machine.

New! Teaching Resources: These assignments are described in the 2018 SIGCSE publication. They are provided for free use under the Creative Commons License (CC BY-NC-SA). Summary of license is provided here.