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
.
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.
- Please follow these instructions for installing Anaconda. When this is done, you should have Anaconda Navigator installed.
- Create a folder called
python-intro
on your computer. - Download python-novice-inflammation-data.zip,
and move the file to
python-intro
. - Unzip
python-novice-inflammation-data.zip
into thepython-intro
folder. - Open Anaconda Navigator.
- Under the "Home" tab on Anaconda Navigator, search for and install "Jupyter Notebook".
- Under the "Environments" tab on Anaconda Navigator, click on the
arrow for the
base
environment. Select "Open terminal". - Type
pip install numpy matplotlib
to install the necessary packages and press enter. - Click on the arrow for the
base
environment again. Select the option to "Open with Jupyter Notebook". - Navigate to the
python-intro
directory, and enter thedata
sub-directory. - Under the "New" button (probably near the upper right corner), select "Python 3" to open a notebook.
-
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.