Python for Business: Instructor Notes

Overall

This lesson is written as an introduction to Python, but its real purpose is to introduce the single most important idea in programming: how to solve problems by building functions, each of which can fit in a programmer’s working memory. In order to teach that, we must teach people a little about the mechanics of manipulating data with lists and file I/O so that their functions can do things they actually care about. Our teaching order tries to show practical uses of every idea as soon as it is introduced; instructors should resist the temptation to explain the “other 90%” of the language as well.

Since these lessons are voiced towards business students with previous experience using spreadsheets, it is frequently helpful to preface your discussion of any new topic with a reference to the spreadsheet operation. By showing the Excel analogue first, many students more quickly grasp what is being taught because they have a way to analogize around the problem.

  1. Show (or ask) how to carry out a task using Excel.
  2. Show the task in Python.
  3. Extend the task using Python.
  4. Ask how to carry out the extension in Excel—this is often not straightforward, particularly as tasks get more complex.

Explain that we use Python because:

Watching the instructor grow programs step by step is as helpful to learners as anything to do with Python. Resist the urge to update a single cell repeatedly (which is what you’d probably do in real life). Instead, clone the previous cell and write the update in the new copy so that learners have a complete record of how the program grew. Once you’ve done this, you can say, “Now why don’t we just break things into small functions right from the start?”

The discussion of command-line scripts assumes that students understand standard I/O and building filters, which are covered in the lesson on the shell.

Frequently Argued Issues (FAI)

After discussing the challenges is a good time to introduce the b *= 2 syntax.