Prequel Python Tutorials

In the week before the Hack Week, we hosted two tutorials to introduce Python to students and scientists who are new to Python. These tutorials were held on Monday, June 21 and Tuesday, June 22 at 15 UTC (5 pm CEST / 11 am EDT / 8 am PDT). Each tutorial lasted about an hour. This tutorial was adapted from Software Carpentry's Programming with Python tutorial.

To replicate the Python environment for this tutorial, please go to the following Binder link. You can access the Jupyter notebook used for the tutorial by opening PythonIntro2021.ipynb.

Binder

Tentative schedule

Day 1

  • Python fundamentals
  • Reading in data
  • NumPy arrays
  • Plotting with matplotlib

Day 2

  • Loops
  • Lists
  • Conditionals
  • Functions

Setup

To follow along with these tutorials, you can either install Python on your own computer, or access a Binder link that will create an environment automatically.

Getting set up on your own computer

If you would like to follow along with the tutorial on your own computer, please follow these instructions.

  1. Please follow these instructions for installing Anaconda. When this is done, you should have Anaconda Navigator installed.
  2. Create a folder called python-intro on your computer.
  3. Download python-novice-inflammation-data.zip, and move the file to python-intro.
  4. Unzip python-novice-inflammation-data.zip into the python-intro folder.
  5. Open Anaconda Navigator.
  6. Under the "Home" tab on Anaconda Navigator, search for and install "Jupyter Notebook".
  7. Under the "Environments" tab on Anaconda Navigator, click on the arrow for the base environment. Select "Open terminal".
  8. Type pip install numpy matplotlib to install the necessary packages and press enter.
  9. Click on the arrow for the base environment again. Select the option to "Open with Jupyter Notebook".
  10. Navigate to the python-intro directory, and enter the data sub-directory.
  11. Under the "New" button (probably near the upper right corner), select "Python 3" to open a notebook.
  12. Test the installation by entering

    import numpy
    import matplotlib.pyplot
    data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')
    matplotlib.pyplot.plot(data)
    matplotlib.pyplot.show()
    

    Press shift-enter to run the cell. If you get a fancy plot, you're all set! If you run into any errors, please ask on the Discord channel for the Hack Week in the #tutorial-python channel.