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?
Inputs:
temp: float
- The temperature valueunit: 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
courses_natalie = ['Late British Literature', 'Toplogy', 'Early Greek Mythology']
courses_nausicaa = ['Organic Chemistry', 'Late British Literature', 'Topology']
courses_hotaru = ['Topology']
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: