From 5ab9cb2535315b3f4727791a6c5873f9aa36b271 Mon Sep 17 00:00:00 2001 From: Tsah Date: Tue, 4 Aug 2026 17:53:31 +0300 Subject: [PATCH] feat: add temperature conversion helpers --- python/temperature.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 python/temperature.py diff --git a/python/temperature.py b/python/temperature.py new file mode 100644 index 0000000..8bafaf5 --- /dev/null +++ b/python/temperature.py @@ -0,0 +1,13 @@ +ABSOLUTE_ZERO_C = -273.15 + + +def celsius_to_fahrenheit(celsius): + if celsius < ABSOLUTE_ZERO_C: + raise ValueError("below absolute zero") + return celsius * 9 / 5 + 32 + + +def celsius_to_kelvin(celsius): + if celsius < ABSOLUTE_ZERO_C: + raise ValueError("below absolute zero") + return celsius - ABSOLUTE_ZERO_C