Start Somewhere: Programming Fundamentals with Python

Welcome to the BioData Club Programming Fundamentals workshop!

Why should you learn to program?

Arguments in favor of learning to code are usually tied to market value. It’s seen as a way to advance or change your career, it’s an economic advantage, it’s something to put on your resume. But we can draw an analogy with learning to cook. People learn to cook for a wide variety of reasons, not just to achieve a goal of becoming a professional chef. Maybe they want to eat better, or spend less money on food. If we decouple learning to code from economic concerns, it becomes a different activity. Maybe you just want to make your life easier. Maybe you enjoy making things. Maybe you’ll discover that you find programming a rewarding activity in itself. From this point of view, the software you might create in the future is more like a home-cooked meal, or a hand-knit sweater.

Any tedious, repetitive task you’ve ever had to perform at a computer can probably be automated with a programming language. It can save you a lot of time and frustration. Analyzing data generated by an experiment, creating reports, scraping data off of websites, automatically generating and formatting spreadsheets – these are all things that are possible when you learn to program.

The caveat is that a two-hour workshop is not going to turn you into a programmer any more than a two-hour workshop could turn you into a chef (or even a home cook), but it’s enough to familiarize yourself with the fundamental concepts and create a base you can build upon.

Credit to Robin Sloane for the learning to cook analogy.

Why are we learning Python?

Our goal is more about teaching the basic concepts that all programming depends on, but there are several good reasons for starting with Python. It’s free, it’s popular, it has excellent documentation, it runs on all platforms (including in the web browser, which is how we’ll be using it today), it’s user base includes many scientists, and it’s among the easiest programming languages to learn.

What’s the format of this workshop and the lessons?

Our materials are excerpted from the Programming with Python lesson produced by a nonprofit organization called Software Carpentry, whose goal is to teach computing skills to researchers. This lesson contains four “episodes”, each focused on a specific programming concept. You can follow along with your instructors with this website, but there are no slides – we will be coding live, and you are invited to follow along on your own computer. Each lesson includes at least one exercise that you will be asked to try on your own, and if time allows, your instructor will walk through it for everyone before moving on to the next episode. We invite you to try out the full lesson (linked above) on your own after the workshop, and join us in the #python channel on the BioData Club Slack if you ever need help.

Prerequisites

You can use a Python interpreter mentioned in the Setup.

The commands in this lesson pertain to Python 3.

Getting Started

To get started, follow the directions on the “Setup” page to get into a Python interpreter.

Schedule

Setup Download files required for the lesson
00:00 1. Python Fundamentals What basic data types can I work with in Python?
How can I create a new variable in Python?
Can I change the value associated with a variable after I create it?
00:30 2. Repeating Actions with Loops How can I do the same operations on many different values?
01:00 3. Storing Multiple Values in Lists How can I store many values together?
01:30 4. Making Choices How can my programs do different things based on data values?
02:00 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.