Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created June 27, 2020 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/b90689906952734ea244b87c07244b4f to your computer and use it in GitHub Desktop.
Save Allwin12/b90689906952734ea244b87c07244b4f to your computer and use it in GitHub Desktop.
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