The best way to learn how to program is to do something useful, so this introduction to Python is built around a common scientific task: data analysis.
Our real goal isn’t just to teach you Python, but to teach you the basic concepts that all programming depends on. We use Python in our lessons because:
- we have to use something for examples;
- it’s free, well-documented, and runs almost everywhere;
- it has a large (and growing) user base among scientists; and
- experience shows that it’s easier for novices to pick up than most other languages.
But the two most important things are to use whatever language your colleagues are using, so that you can share your work with them easily, and to use that language well.
Setup
You need to download some files to follow this lesson. First, you need to open a terminal:
- On Windows: run “Git Bash”, which you installed as part of the software prerequisites
- On Mac OS X: accessed by opening the “Terminal” application, which can be found in the “Utilities” folder which is in your “Applications” folder
- On Linux: this will depend on the Linux distribution you are running, but you should be able to find a “Terminal” application in your desktop’s application menu
Once you’ve done this, a window should appear. Type the following into the prompt that appears (pressing enter/return after each line):
$ cd
$ git clone https://github.com/Southampton-RSG/swc-python-novice-websci.git
Alternatively, if you have SSH authentication with GitHub enabled (if you don’t know what this means don’t worry, it is covered in the Git SWC course if you want to know more!) you can use the following:
$ cd
$ git clone git@github.com:Southampton-RSG/swc-python-novice-websci.git
This should download all the content for the lesson to a new directory. Please let the instructors know if you run into any problems.
Topics
- Python basics: Running the Python interpreter and Variables
- Arrays and Lists
- Repeating actions with loops
- Processing data files
- Making choices
- Creating functions
- Handling Errors
- Command-Line Programs
- Reading and analysing Patient data using libraries
- Visualising data using libraries
- Python Style Guide