This lesson is an introduction to programming in Python for people with little or no previous programming experience. It uses plotting as its motivating example, and is designed to be used in both Data Carpentry and Software Carpentry workshops. This lesson references the Jupyter Notebook, but can be taught using a regular Python interpreter as well. Please note that this lesson uses Python 3 rather than Python 2.
Under Design
This lesson is currently in its early design stage; please check the design notes to see what we have so far. Contributions are very welcome: we would be particularly grateful for exercises and for commentary on the ones already there.
Prerequisites
Learners need to understand what files and directories are, what a working directory is, and how to start a Python interpreter.
Learners must install Python before the class 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 | Download files required for the lesson | |
00:00 | 1. Running and Quitting | How can I run Python programs? |
00:15 | 2. Variables and Assignment | How can I store data in programs? |
00:35 | 3. Data Types and Type Conversion |
What kinds of data do programs store?
How can I convert one type to another? |
00:40 | 4. Built-in Functions and Help |
How can I use built-in functions?
How can I find out what they do? What kind of errors can occur in programs? |
01:00 | 5. Lists | How can I store multiple values? |
01:20 | 6. Tuples & Dictionaries | How can I add semantic value to my collections of multiple values? |
01:35 | 7. Break | Break |
01:50 | 8. Libraries |
How can I use software that other people have written?
How can I find out what that software does? |
02:00 | 9. Reading Tabular Data into DataFrames | How can I read tabular data? |
02:20 | 10. Plotting | How can I plot my data? |
02:25 | 11. Writing Functions | How can I create my own functions? |
02:50 | 12. For Loops | How can I make a program do many things? |
03:05 | 13. Conditionals | How can programs do different things for different data? |
03:25 | 14. Wrap-Up Exercise | How can we put together all of today’s material? |
03:45 | 15. Pandas DataFrames | How can I do statistical analysis of tabular data? |
03:50 | 16. Command-Line Programs | How can I write Python programs that will work like Unix command-line tools? |
04:37 | 17. Defensive Programming | How do I predict and avoid user confusion? |
04:52 | 18. 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? |
05:03 | 19. Running Scripts and Importing | How can I import some of my work even if it is part of a program? |
05:33 | 20. Programming Style |
How can I make my programs more readable?
How do most programmers format their code? How can programs check their own operation? |
05:43 | 21. Wrap-Up |
What have we learned?
What else is out there and where do I find it? |
06:03 | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.