Find us on GitHub

Teaching basic lab skills
for research computing

Python

Novices (and people looking for an argument) often ask, "What's the best programming language?" The answer depends on what we want to do. If we want to squeeze the last ounce of performance out of our hardware, then compiled languages like C++, C#, and Fortran are still good options, but if we want to write small programs quickly, and be able to manage the complexity of larger ones, then dynamic languages like Python, Ruby, R, and MATLAB optimize development time, which is often the biggest bottleneck for researchers. Learning how to structure a program as reusable pieces, each of which is small enough to fit into a programmer's working memory, is the key to building large programs efficiently.

  • Variables are labels that refer to data.
  • Use while to repeat something until something changes.
  • Use for to do something once for each part of a larger whole.
  • Use if and else to make choices.
  • Use lists to store many related values in order.
  • Use strings to store text.
  • Many variables may refer to the same piece of data.
  • Define functions to break programs down into manageable pieces.
  • Remember that a function is really just another kind of data.
  • Use libraries to group related functions and other definitions together.
  1. Introduction
  2. Basics
  3. Control Flow
  4. Lists
  5. Input and Output
  6. Strings
  7. Aliasing
  8. Interluce: Using a Debugger
  9. Functions
  10. First Class Functions
  11. Libraries
  12. Tuples
  13. Slicing
  14. Text