14 lines
395 B
Python
14 lines
395 B
Python
class Celsius(object):
|
|
"""docstring for Celsius"""
|
|
def __init__(self, temperature=0):
|
|
super(Celsius, self).__init__()
|
|
self.temperature = temperature
|
|
|
|
@classmethod
|
|
def from_fahrenheit(cls, temperature=32):
|
|
temperature = (temperature - 32) / (9 / 5)
|
|
return cls(temperature)
|
|
|
|
def to_fahrenheit(self):
|
|
return (self.temperature * 1.8) + 32
|