Functional Libraries

Jed Rembold

January 26, 2026

Happy Monday!

  • Scan the QR code or go to https://tools.jedrembold.prof/daily
  • Class code is 2FvLMX
  • Introduce yourselves! Fun question: If you had a magic box that consumed one type of object and output another, what would the inputs and outputs be?

Quick Announcements

  • Problem Set 1 is due tonight!
  • My Monday office hours need to change due to a meeting
    • Now from 2:00-2:45pm on Mondays
    • Can potentially catch me between 5:30 and 6:30 as well
  • Problem Set 2 posted by end of day, due next Monday night

Group Problems

Problem 1: The Assembly Line

  • Each group has been handed a set of functions, one of which should be given to each individual. If you have fewer people, one person can double up.
  • The blank slips of paper should be distributed amongst everyone
  • Clustering around may be easier than being stretched out in a line
  • Your overall goal is to determine the final printed number.

Problem 1: How it works

  • The individual with the person_D function starts things off
  • Whenever a function is called in your code, you must write any inputs to that function on a slip of paper, and then hand that paper to whichever individual is in charge of the function that you are calling.
  • You then must continue to hold out your hand until that function/person returns a slip of paper to you. Then you can continue with your program.
  • If your function ever prints something, you need to say that value out loud whenever you hit that line of code.

Problem 2: The Bureau of Standards

  • Your group is tasked with creating a simple library of conversion functions
  • Each individual should choose one of the conversions to the right, and write two functions: one that converts one direction, and one that converts the other
  • Collect all of these functions together into a single file called conversions.py. It may be useful to use something like a shared Google Doc for quick sharing, or you can just dictate/copy from each other.
  • Feet to Kilometers
  • Pounds to Grams
  • Fahrenheit to Celsius
  • Cups to Liters

Problem 2: Calling BS

  • Now, in a separate file, write a program to solve the following word problem, importing in what functions you need.

Johnny needs his 2000 lb car to travel 2000 feet down the road. He knows that it normally takes 1 cup of gas to move 5000 grams 0.5 kilometers down the road, when the temperature is 20 degrees Celsius. But for each degree Celsius above that, it takes an addition 0.5 liter of gas to move the 5000 grams 0.5 kilometers down the road. It is 83 degrees F outside. How many liters of gas does Johnny need?

Problem 3: The Error Doctor

  • In the materials for today there are three problems named
    • Error1.py
    • Error2.py
    • Error3.py
  • Each contains a function and a comment that explains the expected output. But something is wrong.
  • Identify what is wrong in each case and how you could easily fix it.
// reveal.js plugins