Created
November 11, 2016 04:21
-
-
Save kottenator/7e748b61fd8fb7c79a993b2e97db5970 to your computer and use it in GitHub Desktop.
Simple temperature calculator (°C / °F)
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
c = lambda f: (f - 32) * 5 / 9.; f = lambda c: c * 9 / 5. + 32; print('\n'.join(u'{2:>6} °C ← °F {0:>4} °C → °F {1:6}'.format(i * 10, f(i * 10), round(c(i * 10), 1)) for i in range(-10, 11))) |
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
def c(f): | |
return (f - 32) * 5 / 9. | |
def f(c): | |
return c * 9 / 5. + 32 | |
print('\n'.join( | |
u'{2:>6} °C ← °F {0:>4} °C → °F {1:6}'.format( | |
i * 10, f(i * 10), round(c(i * 10), 1) | |
) for i in range(-10, 11) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment