From f67edda7c5b98802ef044c2762b8737e3249f3d7 Mon Sep 17 00:00:00 2001 From: b1nary-c0de <51186970+b1nary-c0de@users.noreply.github.com> Date: Sun, 5 Apr 2020 14:59:03 +0530 Subject: [PATCH] Temperature Unit Conversion [FEATURE] (#194) Celsius to Fahrenheit and back Co-authored-by: Angelos Chalaris --- snippets/celsius_to_fahrenheit.md | 17 +++++++++++++++++ snippets/fahrenheit_to_celsius.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 snippets/celsius_to_fahrenheit.md create mode 100644 snippets/fahrenheit_to_celsius.md diff --git a/snippets/celsius_to_fahrenheit.md b/snippets/celsius_to_fahrenheit.md new file mode 100644 index 000000000..1ea9ff4e3 --- /dev/null +++ b/snippets/celsius_to_fahrenheit.md @@ -0,0 +1,17 @@ +--- +title: celsius_to_fahrenheit +tags: math,beginner +--- + +Converts Celsius to Fahrenheit. + +Use the formula `fahrenheit = (celsius * 1.8) + 32` to convert from Celsius to Fahrenheit. + +```py +def celsius_to_fahrenheit(celsius): + return ((celsius * 1.8) + 32) +``` + +```py +celsius_to_fahrenheit(180) # 356.0 +``` diff --git a/snippets/fahrenheit_to_celsius.md b/snippets/fahrenheit_to_celsius.md new file mode 100644 index 000000000..976f9b3db --- /dev/null +++ b/snippets/fahrenheit_to_celsius.md @@ -0,0 +1,17 @@ +--- +title: fahrenheit_to_celsius +tags: math,beginner +--- + +Converts Fahrenheit to Celsius. + +Use the formula `celsius = (fahrenheit - 32) / 1.8` to convert from Fahrenheit to Celsius. + +```py +def fahrenheit_to_celsius(fahrenheit): + return ((fahrenheit - 32) / 1.8) +``` + +```py +fahrenheit_to_celsius(77) # 25.0 +```