27 lines
436 B
Python
27 lines
436 B
Python
|
#!/usr/bin/env python3
|
||
|
# coding: utf8
|
||
|
|
||
|
"""016-temperatures.py"""
|
||
|
|
||
|
def fahrenheit_to_celsius(temp_f):
|
||
|
"""
|
||
|
:Examples:
|
||
|
>>> fahrenheit_to_celsius(212)
|
||
|
100.0
|
||
|
"""
|
||
|
return ((temp_f - 32) / float("1.8"))
|
||
|
|
||
|
|
||
|
def celsius_to_fahrenheit(temp_c):
|
||
|
"""
|
||
|
:Examples:
|
||
|
>>> celsius_to_fahrenheit(100)
|
||
|
212.0
|
||
|
"""
|
||
|
return ((9/5) * temp_c + 32)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
import doctest
|
||
|
doctest.testmod()
|