Temperature Unit Conversion [FEATURE] (#194)

Celsius to Fahrenheit and back

Co-authored-by: Angelos Chalaris <chalarangelo@gmail.com>
This commit is contained in:
b1nary-c0de
2020-04-05 14:59:03 +05:30
committed by GitHub
parent 728aa7dd82
commit f67edda7c5
2 changed files with 34 additions and 0 deletions

View File

@ -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
```

View File

@ -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
```