Skip to content

Instantly share code, notes, and snippets.

@Allwin12 Allwin12/temp.py
Created Jun 27, 2020

Embed
What would you like to do?
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
You can’t perform that action at this time.