Problem Set 1, Spring 2020

This problem set is worth 17.5% of the grade in this course. It is due on Friday, February 7, at 5pm, via email to Diana Dewalle. It has four short questions, each of which is worth 25 points.

How to turn in this problem set: each of the problems asks you to write a single Python function which carries out a designated operation. You should include working code for each of these functions in a single Jupyter Notebook file, entitled lastname_ps1.ipynb (obviously with your last name), which you will turn in to the dropbox on ICON. The filename should be the only place with your name in it. Diana Dewalle will anonymize the files by replacing the name with a number before sending them to me to grade.

  • For each of the problems, you need not package all of your code in a single function. For example, you may write helper functions, import libraries outside of your function, etc. However, you must turn in a single Jupyter Notebook file with all the code that makes your functions work as well as the functions themselves. I expect to be able to run all the cells in the notebook you turn in, and, at the end, have a working function for each problem, so that I can call those functions with appropriate input and get the correct result. In all cases, your functions should return None if they receive inappropriate input.


Each student must agree to the following honor code; if you do not agree to this honor code, do not turn in this problem set and drop the course.

I will not solicit, receive, or provide any unauthorized assistance on this or any problem set in this course. I understand that unauthorized assistance includes seeing the work of any other student, including code, calculations, data analysis, or answers to problems. Students are permitted to discuss their general strategies for solving problems with one another, help one another understand lesson material or documentation for Python libraries, and the like, or other conversation short of sharing actual answers, calculations, data analysis, or code. Students are not permitted to seek or receive assistance or advice whatsoever from any person not enrolled in this course---this prohibition includes asking for help on public online forums such as, although students are free to search such websites and learn from preexisting discussions in which they are not participants.

If I have any doubt about the permissibility of any kind of assistance, I will seek a ruling from the professor. I will report any violations of this honor code of which I am aware. Violating this honor code is grounds for immediate disenrollment from this course, or other sanctions as provided for by College of Law and University policy on academic dishonesty.

Problem 1: Your First Class

Write a class, called Citation, which takes the following required parameters: first_page (an integer), last_page (an integer), reporter (a string), and year (an integer), as well as the optional parameter name (a string). That class should have the method cite() which will print out a citation to the case, using all of the information it has.

For example, I should be able to create a citation in either of the following forms:

my_case1 = Citation(20, 15, "U.S.", 2050)

my_case2 = Citation(20, 15, "U.S.", 2050, name="Gowder v. Fictional Opponent")

and then if I call print(my_case2.cite()) I should get back Gowder v. Fictional Opponent, 20 U.S. 15 (2050).

Problem 2: Extracting Citations

Write a function called scotus_finder() that can take a string with some unknown number of citations to the U.S. Supreme Court in it, and return a list of Citation objects as in the previous problem. Your function should be able to handle cases cited to either the U.S. reporter ("U.S.") or to the Supreme Court reporter ("S.Ct.") (you don't need to handle "L.Ed." or any of the weird old reporters). You do not need to be able to identify the name of the case. You may assume that citations are in the standard form, e.g., 123 S.Ct. 456 (2001).

For example,

my_string = "The best case in the world is Prince v. The End of the Century, 22 U.S. 50124 (1999), and I like it"

found_cases = scotus_finder(my_string)


should print 22. U.S. 50124 (1999)

Problem 3: Fun with APIs

Using the Caselaw Access Project API, find answers to the following question; please show your code as well as your answer:

What is the citation for the most recent case in Iowa that uses the word "feline?"

Problem 4: Fun with APIs continued

Using the same API as before: How many total times has the word "pork" been used in cases from the Iowa state courts in the CAP database? (Note: not number of cases, I want number of uses of the word.)