Introducing Programming Through Python

Day 1 Goals:

Despite what the title above might suggest, the purpose of this Software Carpentry bootcamp is __not__ to teach you how to program in Python. While we do love Python for scientific computing, the goals of these modules is actually to teach you the basic, core concepts of programming that transcend languages, how they fit together, and how you can use them to become a better scientist.

By the end of these scientific Python lessons, you will be able to:

  1. Describe and distinguish the seven core elements shared by all programming languages.
  2. Use Python to write simple programs that use these core elements, using both the core library and scientific packages such as numpy.

Day 2 Goals:

  1. Make and save simple publication-quality plots using matplotlib.
  2. Read, manipulate, and save data files in csv and text formats.
  3. Write unit tests to confirm the accuracy of your Python code.

The Seven Core Concepts

As noted by Greg Wilson (the founder of Software Carpentry), every programming language shares [seven core elements][1]:

  1. Individual things (the number 2, the string ‘hello’, a matplotlib figure)
  2. Commands that operate on things (the + symbol, the len function)
  3. Groups of things (Python lists, tuples, and dictionaries)
  4. Ways to repeat yourself (for and while loops)
  5. Ways to make choices (if and try statements)
  6. Ways to create chunks (functions, objects/classes, and modules)
  7. Ways to combine chunks (function composition)

We expect that you’ll find the basics of 1 and 2 fairly straightforward, and will go quickly through those, and will spend the most time on items 3-6. We won’t really talk about 7, as it is not as common in scientific Python programming as it is in, say, shell scripting (pipes and redirection).

Don’t worry if you don’t already know what all of the above examples mean - you’ll know by the end of this lesson.

comments powered by Disqus

Table Of Contents

Previous topic

Introducing Python

Next topic

Running IPython Notebook

This Page




Edit this document!

This file can be edited directly through the Web. Anyone can update and fix errors in this document with few clicks -- no downloads needed.

  1. Go to Introducing Programming Through Python on GitHub.
  2. Edit files using GitHub's text editor in your web browser (see the 'Edit' tab on the top right of the file)
  3. Fill in the Commit message text box at the bottom of the page describing why you made the changes. Press the Propose file change button next to it when done.
  4. Then click Send a pull request.
  5. Your changes are now queued for review under the project's Pull requests tab on GitHub!

For an introduction to the documentation format please see the reST primer.