can someone show me some code to convert rankine temperature to kelvin? rankine is in the same scale as fahrenheit, but it starts at absolute zero. so 0R = -459.67F, heres is what I have
convert to kelvin
def __init__(self, value=0):
Fah=value-459.69
Cel=(Fah-32)*5/9.0
value=Cel-273.15
Temperature.__init__(self, value)
convert back to rankine
def __str__(self):
Cel=self.value+273.15
Fah=Cel*1.8+32
self.value=Fah+459.69
return Temperature.__str__(self, 'R')
for anyone wondering, this is an assignment where I have to store a temperature using a base value (i decided the base will be in kelvin degrees) in a class called "Temperature()"
I have child classes for kelvin, celsius, fahrenheit, and rankine. I have to be able to store all the temperature in the kelvin equivalent and then be able to print them out in their native (such as celsius, or fahrenheit) values. so if I did
a=TempK(100)
print a
it will print
The Temperature is = 100K
if I do
b=TempC()
print b
it will say
The Temperature is = 0C
and if I do
b.set(a)
print a
it is supposed to set a (TempC()) to the kelvin equivalent of whatever b is (TempK()) and then print it out in celsius. which would do this
The Temperature is = -173.15C
I have fahrenheit, celsius and kelvin all working, I just can't seem to get rankine to convert correctly