Summary and Schedule
This lesson build on the Plotting and Programming in Python lesson developed by Software Carpentry. For a review challenge of of the python needed for this lesson, please see the extra review episode.
This lesson also requires knowledge of the Unix Shell and Version Control with Git - incubator version with branches. This lesson works with both Jupyter Notebooks and writing scripts with a text editor to be run in the shell.
Prerequisites
Learners are expected to have been introduced to the material from the Unix Shell lesson, the Plotting and Programming in Python lesson, and the Version Control with Git - incubator version with branches.
Learners must install Python before the workshop starts.
Learners must get the gapminder data before class starts: please download and unzip the file python-novice-gapminder-data.zip.
Please see the setup instructions for details.
| Setup Instructions | Download files required for the lesson | |
| Duration: 00h 00m | 1. Command-Line Programs | How can I write Python programs that will work like Unix command-line tools? |
| Duration: 00h 30m | 2. Trying Different Methods | How do I plot multiple data sets using different methods? |
| Duration: 01h 00m | 3. Program Flags | How can I make an easy shortcut to analyze all files at once using a program flag? |
| Duration: 01h 10m | 4. Defensive Programming | How do I predict and avoid user confusion? |
| Duration: 01h 25m | 5. Refactoring |
When should I reorganize my code so it is more clear and readable for
others? How can I organize my code so that it is useable in other places? Why do I almost always want to write my code as though it will be used somewhere else? |
| Duration: 01h 45m | 6. Running Scripts and Importing | How can I import some of my work even if it is part of a program? |
| Duration: 02h 05m | 7. Wrap-Up |
What have we learned? What else is out there and where do I find it? |
| Duration: 02h 15m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Setup
Installing Python
Follow the directions listed in the python installation section of Carpentries workshop website template for your operating system.
Getting the Data
The data we will be using is taken from the gapminder dataset. To obtain it, download and unzip the file python-novice-gapminder-data.zip. In order to follow the presented material, you should launch a Jupyter notebook in the root directory (see Starting Python section below).
Starting Python
We will teach Python using the Jupyter
lab, a programming environment that runs in a web browser. Jupyter
requires a reasonably up-to-date browser, preferably a current version
of Chrome, Safari, or Firefox (note that Internet Explorer version 9 and
below are not supported). If you installed Python using conda
and have setup the carpentries conda environment, Jupyter
should already be on your system.
To start the notebook, open a terminal or git bash or miniforge prompt.
Then, activate the carpentries conda enviornment
Then, navigate to your project folder. If it is called
swc and located on your Desktop it might look
something like this:
then launch jupter:
To start the Python interpreter without the notebook, open a terminal or Git Bash or miniforge prompt and type the command: