Programming 101

A practical guide to learning Python.

Posted by Abhi Desai on July 19, 2016

Introduction

Do you have tedious computer tasks that you wish you had an intern for?

  • I have a folder with thousands of files that need to be renamed
  • I need to look through thousands of rows in an Excel spreadsheet looking for ones to update
  • I have to pull text off of several web pages
  • I want to copy the data from hundreds of PDFs

Normally this would involve hours of mindless clicking and typing. But programming your computer to do it will save you time and effort.

Regardless of what profession a person pursues in modern society, computers will be a central tool. Therefore, learning to program - that is, learning to interface in a complex way with the machine - is a critical and invaluable skillset. Everyone should learn to code, but not everyone needs to become a software engineer or computer scientist. This article is for office workers, students, administrators, and anyone who uses a computer to learn how to code small, practical programs to automate tasks using free online resources.

There is a fundamental problem with the way people are introduced to programming. Almost every “intro to programming” class in existence follows this pattern:

  • Class 1-10: an enormous amount of syntax and/or object-oriented principles so that students can even begin to understand code written in Java or BASIC or C++
  • Class 11: learn what a for loop is, and do a dozen incredibly basic problems with for loops.
  • Class 12: learn what a while loop is, and do a dozen incredibly basic problems with while loops.
  • etc, ad nauseum.

I think this turns people off to programming from the start: students either begin to think that programming is inherently complex and difficult, or that its a useless skill since they don’t intend to be “programmers” and have no use for such abstract knowledge.

Instead, I propose to you an alternative approach:

How to Learn Python

  1. Install the Anaconda distribution, which includes:
    • the most recent version of Python,
    • 1500+ libraries you are likely to use,
    • and support for Jupyter notebooks (you’ll see why these are indispensible later)
  2. Find a tedious computer task in your life like mentioned in the introduction above.
  3. Read Part 1 (the first six chapters) of Automate the Boring Stuff.
  4. Use CodingBat to gamify your learning and make sure you’re on the right track. When the problems get easy and redundant, move on to ProjectEuler.
  5. Read the chapters of Automate the Boring Stuff that are relevant to your tedious task. I recommend reading the entire book if you have a spare weekend or two; its not very long and will provide a robust foundation for you to build off of going forward.
  6. Remember to use packages developed by others to their fullest extent.
  7. Learn to use Jupyter notebooks, which will allow you to easily collaborate with others, develop interactive programs, and easily debug your code.