Temperature Unit Conversion [FEATURE] (#194)
Celsius to Fahrenheit and back Co-authored-by: Angelos Chalaris <chalarangelo@gmail.com>
This commit is contained in:
17
snippets/celsius_to_fahrenheit.md
Normal file
17
snippets/celsius_to_fahrenheit.md
Normal 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
|
||||
```
|
||||
17
snippets/fahrenheit_to_celsius.md
Normal file
17
snippets/fahrenheit_to_celsius.md
Normal 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
|
||||
```
|
||||
Reference in New Issue
Block a user