Find us on GitHub

Teaching basic lab skills
for research computing

Python: Introduction

Python/Introduction at YouTube

Hello, and welcome to the first episode of the Software Carpentry lecture on Python. In this episode, we'll explain why we're teaching Python, and talk about how it compares with other languages.

Whenever you're programming, the total time to get a solution is determined by:

how long it takes to write a program, and

how long it takes that program to run.

The first is human time: the time to get a correct program running is primarily determined by how fast you can think.

The second is machine time: the faster the computer, the faster you'll have your answer.

Every programming language makes a tradeoff between these two kinds of time.

High-level languages like Python

and MATLAB try to make programming itself faster by doing more for you.

Low-level languages like Fortran

and C, on the other hand, do less for you, but also hide less from you, which allows for greater optimization.

And in between, there are languages like Java

and C#, which do some things automatically, but leave others in your hands.

So, why have we chosen to use Python?

First, teaching you Python isn't actually the point of this course—what we really want to teach are computational thinking and fundamental computational skills.

But we have to write our examples in some language…

…and we have found that Python is easier to pick up than other languages which are also:

free,

run on lots of different machines,

widely used,

well documented, and

well supported: thousands of Python libraries exist, many of them written specifically for scientific applications.

Before we get started, please note: this lecture will not teach you basic programming.

Instead, we assume you already know at least a little bit about:

variables,

loops,

conditionals (i.e., 'if' and 'else'),

lists or arrays, and

how to read data from a file.

What we'll do in the next dozen episodes is show you how to do these things in Python.

More specifically, how to do them well in Python.

So, let's get started.