Jump to content

Temperature conversion: Difference between revisions

→‎{{header|D}}: Add Python.
(→‎{{header|D}}: added D)
(→‎{{header|D}}: Add Python.)
Line 75:
R 37.80
</pre>
 
=={{header|Python}}==
<lang python>Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> while True:
k = float(input('K ? '))
print("%g Kelvin = %g Celsius = %g Fahrenheit = %g Rankine degrees."
% (k, k - 273.15, k * 1.8 - 459.67, k * 1.8))
 
K ? 21.0
21 Kelvin = -252.15 Celsius = -421.87 Fahrenheit = 37.8 Rankine degrees.
K ? 222.2
222.2 Kelvin = -50.95 Celsius = -59.71 Fahrenheit = 399.96 Rankine degrees.
K ?
Traceback (most recent call last):
File "<pyshell#4>", line 2, in <module>
k = float(input('K ? '))
KeyboardInterrupt
>>> </lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.