Midterm

Congratulations; we are about two-thirds through the course! We will now review what you've learned so far by checking your understanding! This is an optional assignment provided to gauge how well you've absorbed material we've covered thus far.

Q1

Consider a situation where you have a temperature value and its current unit, which could either be Fahrenheit ('F') or Celsius ('C'). Your task is to convert this temperature value to the other temperature unit. Below, you will find the formulas needed for the conversion. Make sure to round off your final result to two decimal places for precision. Can you write a function to accomplish this task?

c = \frac{f-32}{1.8} f = 1.8c+32

Inputs:

  • temp: float - The temperature value
  • unit: str - The unit the input temp value starts in.

Constraints: temperature is a float; returned value should be a float.

temp:

unit:

Q2

Given a list of tuples (temp, unit, day), return the average temperature in celcius for each day. The results should be rounded to two decimal places. (Note, days should be stored in a dictionary, if a day isn't provided, it shouldn't be in the dict).

Constraints: days are categorical.

temp:

unit:

day:

Q3

Natalie, Nausicaa, and Hotaru are friends that are interested in taking a course together. Natalie and Nausicaa know what courses they want to take and Hotaru doesn't care, only she knows what courses she doesn't want to take. Help these friends find a course to take together. Return a set of possible courses.

Constraints: courses are categorical.

Example

Using the example above, Natalie and Nausicaa have course overlap in 'Late British Literature' and 'Topology'. However Hotaru doesn't want to take 'Topology', and so should be excluded. Thus the result should be Late British Literature.

courses_natalie:

courses_nausicaa:

courses_hotaru: