Home Segments Index Top Previous Next

119: Practice

Write a function named c_to_f that transforms an integer argument into twice that integer plus 30.

Next, amend your c_to_f function such that it displays “Performing an approximate temperature conversion” every time that it is called.

Next, improve your c_to_f function by having it add 40 to the argument, multiply by 9/5, and subtract 40.

Finally, change your c_to_f function such that the argument is in Celsius degrees relative to absolute zero and the result returned is in Fahrenheit degrees relative to absolute zero. Absolute zero is -273 degrees Celsius.

For each change, comment on the corresponding benefit provided by function abstraction.