CPSC120A
Fundamentals of Computer Science I

Post-lab 8

Fruitful Functions

One of the uses of fruitful functions is to write functions that perform various unit conversions. Already this semester you've re-written the code to convert from kilometers to meters, years to seconds, and vice-versa. However, you can write a function once and reuse that code in many different programs. Today you will demonstrate your knowledge of fruitful functions by writing a function to convert temperatures.

Details

Create a function called fahrenheit_to_celsius(degrees_fahrenheit) in a file called temperatures.py. This function should take as a parameter a floating point value representing the temperature in Fahrenheit and return a floating point value representing the temperature in Celsius.

Recall that the equation to convert from Fahrenheit to Celsius is:

$$ C = (F - 32) \times \frac{5}{9}$$

Test your function by calling the function multiple times with different parameters. Make sure you use proper variable names follow the course's code conventions.

Test Cases

Function Parameters Expected Output
-15 -26.11111111111111
0 -17.77777777777778
32 0.0
100 37.77777777777778
212 100.0

Submission

Submit your program as a .py file on the course Inquire page before class on Wednesday September 17th.