Contents:


  1. Introduction to Programming and Python

    In this first week of the course, we're going to cover some core concepts of computer programming. With this, we will build a foundation to do more interesting things in the coming weeks.

    What is Computer Programming?

    Computers basically just do one thing: they complete very simple operations at astonishing speed.

    For example, suppose you wanted to calculate the thousandth number of the Fibonacci Sequence read more

  2. Files and How Computers Represent Data

    In this lesson, we're going to learn how to open files and work with data from the disk. We'll start with the mechanical process of opening text files, and then move on to learn a little bit more about different kinds of data you'll see.

    Here's the basic method of opening and reading text files. Suppose I have a file called hello.txt in my working directory. (Your working directory is the directory you run Python from on your hard drive. For those of you using Azure Notebooks, this should be your library, but talk to me if you see a file there and can't read it from Python.)

    read more
  3. Functions and Scope

    Recall how in the first Python lesson we looked at the while loop and saw how it allows us to repeat instructions to the computer as many times as you want.

    The next step up from a loop is a function, which allows us to wrap up a series of commands into a single command on its own. Let's take a look at an example.

    read more
  4. Simple Data Types (draft)

    In Python, the data you work with (like the things assigned to variables) have types, which specify the kinds of data they are and the things you can do with them.

    A good way to understand this is to think about the difference between letters and numbers. While we can write both down, there are different things we can do to them. It wouldn't make sense (except in an algebra context) to multiply and divide letters; it would't make sense to talk about a capital and a lowercase number 3.

    read more
  5. Complex Data Types

    Some kinds of data can store other kinds of data.

    Lists

    We've actually seen the most common complex data type a few times before, I just haven't pointed it out to you. We make a list by enclosing the elements of a list in square brackets.

  6. Key Python Libraries for Working with Data

    In this lesson I'm just going to describe the main libraries that we'll see when we work with data in Python.

    Numpy

    Numpy is the first library we work with. By convention, it's imported with import numpy as np. Numpy really provides two things to our workflow:

    1. Math that goes faster than unadorned Python could do it---which is important when you're doing statistics, because under the hood computational stats can take a lot of calculations.

      read more
  7. Object-Oriented Programming

    Object-oriented programming (OOP) isn't all that special, it's just a particular style of programming that Python is particularly well designed for. This is a short lesson, we won't cover the theory of OOP, or features you might hear about elsewhere like "inheritance"---see your reading in the P4E book for more.

    read more
  8. Regular Expressions

    Regular expressions (or "regex"/"regexes") are one of the most powerful programming tools for lawyers. Essentially, regular expressions are a powerful specialized programming language built into other languages like Python, which allow you to express complicated text searching operations.

    The utility of this for lawyers should be obvious: lawyers have to deal with lots and lots and lots of documents, and sometimes need to search through those documents for specific information. If those documents are in electronic form, regular expressions can provide you with a much more powerful way of searching than what is built into ordinary applications.

    read more
  9. In-class example: talking to an API

    This is a lightly edited version of the notebook that we worked through in class on 1/22/19.

    In class, we went through how to make an API call end-to-end, to get a look at common tasks like figuring out documentation, using libraries, making HTTP requests, etc. Over the weekend, practice with this API and others (you might also try the one at opensecrets.org read more

links