Created
June 27, 2020 14:24
-
-
Save Allwin12/b90689906952734ea244b87c07244b4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Temperature: | |
def __init__(self, temperature): | |
self.temperature = temperature | |
def celsius_to_fahrenheit(self): | |
f = (self.temperature/5) + 32 | |
return round(f, 2) | |
def celsius_to_kelvin(self): | |
f = self.temperature + 273 | |
return round(f, 2) | |
def fahrenheit_to_celsius(self): | |
f = 5 * (self.temperature - 32)/9 | |
return round(f, 2) | |
def fahrenheit_to_kelvin(self): | |
f = 5 * (self.temperature - 32)/9 + 273 | |
return round(f, 2) | |
def kelvin_to_celsius(self): | |
f = self.temperature - 273 | |
return round(f, 2) | |
def kelvin_to_fahrenheit(self): | |
f = 9 * (self.temperature/5) + 32 | |
return round(f, 2) | |
t1 = Temperature(100) | |
t1 = t1.celsius_to_kelvin() | |
print(t1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment