-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Lobooooooo14/development
Development
- Loading branch information
Showing
5 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,53 @@ | ||
# Tempyrature | ||
# Tempyrature | ||
|
||
Tempyrature is a simple Python module to convert temperature scales easily. | ||
|
||
*** | ||
|
||
## Scales | ||
|
||
Tempyrature currently supports 3 temperature ranges: | ||
|
||
- Celcius | ||
- Fahrenheit | ||
- Kelvin | ||
|
||
## Installation | ||
|
||
You can install tempyrature in two main ways: | ||
|
||
1. [***Pypi***](https://pypi.org/project/tempyrature/): | ||
|
||
Through the command: | ||
``` | ||
pip install tempyrature | ||
``` | ||
> This command may vary depending on your device. | ||
2. Cloning this repository: | ||
|
||
If you have GIT installed, you can: | ||
|
||
``` | ||
git clone https://github.com/Lobooooooo14/tempyrature.git | ||
``` | ||
This will download this repository to your device, enter the downloaded folder (make sure it is in the same directory as the `setup.py` file) and use the command: | ||
``` | ||
pip install . | ||
``` | ||
|
||
## How to use | ||
|
||
After you have done the installation, you can use the tempyrature as follows: | ||
|
||
```python | ||
from tempyrature import Converter | ||
|
||
|
||
print(Converter.celsius2fahrenheit(30.5)) #30.5°C | ||
#>>> 86.0 | ||
``` | ||
|
||
## Documentation | ||
|
||
You can see the full documentation [***here***](https://github.com/Lobooooooo14/tempyrature/wiki/Documentation) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
""" | ||
A simple temperature converter | ||
tempyrature | ||
----------- | ||
A simple temperature converter. | ||
:copyright: (c) 2022 - Lobooooooo14 | ||
:license: see LICENSE for more details. | ||
""" | ||
|
||
__title__ = "tempyrature" | ||
__author__ = "Lobooooooo14" | ||
__license__ = "Apache License 2.0" | ||
__copyright__ = "Copyright 2022 - Lobooooooo14" | ||
__version__ = "1.0.1" | ||
|
||
__path__ = __import__("pkgutil").extend_path(__path__, __name__) | ||
|
||
|
||
from .tempyrature import Converter |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,192 @@ | ||
__all__ = [ | ||
'Converter' | ||
] | ||
|
||
|
||
class Converter: | ||
""" | ||
A simple temperature converter. | ||
""" | ||
|
||
def __init__(self) -> None: | ||
""" | ||
A simple temperature converter. | ||
""" | ||
pass | ||
|
||
|
||
def celsius2fahrenheit(celsius: float) -> float: | ||
""" | ||
Converts celsius to fahrenheit. | ||
Parameters | ||
---------- | ||
celsius : float | ||
The celsius temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> celsius2fahrenheit(25.0) | ||
77.0 | ||
>>> celsius2fahrenheit(25.3) | ||
77.53999999999999 | ||
Formula | ||
------- | ||
fahrenheit = 1.8 * celsius + 32 | ||
""" | ||
|
||
fahrenheit = 1.8 * celsius + 32 | ||
return fahrenheit | ||
|
||
|
||
def fahrenheit2celsius(fahrenheit: float) -> float: | ||
""" | ||
Converts fahrenheit to celsius. | ||
Parameters | ||
---------- | ||
fahrenheit : float | ||
The fahrenheit temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> fahrenheit2celsius(77.0) | ||
25.0 | ||
>>> fahrenheit2celsius(25.3) | ||
25.299999999999994 | ||
Formula | ||
------- | ||
celsius = (fahrenheit - 32) / 1.8 | ||
""" | ||
|
||
celsius = (fahrenheit - 32) / 1.8 | ||
return celsius | ||
|
||
|
||
def celsius2kelvin(celsius: float) -> float: | ||
""" | ||
Converts celsius to kelvin. | ||
Parameters | ||
---------- | ||
celsius : float | ||
The celsius temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> celsius2kelvin(10.0) | ||
283.15 | ||
>>> celsius2kelvin(10.7) | ||
283.84999999999997 | ||
Formula | ||
------- | ||
kelvin = celsius + 273.15 | ||
""" | ||
|
||
kelvin = celsius + 273.15 | ||
return kelvin | ||
|
||
|
||
def kelvin2celsius(kelvin: float) -> float: | ||
""" | ||
Converts kelvin to celsius. | ||
Parameters | ||
---------- | ||
kelvin : float | ||
The kelvin temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> kelvin2celsius(283.0) | ||
9.850000000000023 | ||
>>> kelvin2celsius(283.84) | ||
10.689999999999998 | ||
Formula | ||
------- | ||
celsius = kelvin - 273.15 | ||
""" | ||
|
||
celsius = kelvin - 273.15 | ||
return celsius | ||
|
||
|
||
def fahrenheit2kelvin(fahrenheit: float) -> float: | ||
""" | ||
Converts fahrenheit to kelvin. | ||
Parameters | ||
---------- | ||
fahrenheit : float | ||
The fahrenheit temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> fahrenheit2kelvin(80.0) | ||
299.81666666666666 | ||
>>> fahrenheit2kelvin(25.7) | ||
300.2055555555555 | ||
Formula | ||
------- | ||
kelvin = 273.15 + ((fahrenheit - 32.0) * (5.0/9.0)) | ||
""" | ||
|
||
kelvin = 273.15 + ((fahrenheit - 32.0) * (5.0/9.0)) | ||
return kelvin | ||
|
||
|
||
def kelvin2fahrenheit(kelvin: float) -> float: | ||
fahrenheit = 1.8 * (kelvin - 273.15) - 32 | ||
""" | ||
Converts kelvin to fahrenheit. | ||
Parameters | ||
---------- | ||
kelvin : float | ||
The kelvin temperature to convert. | ||
Returns | ||
------- | ||
float | ||
The converted temperature. | ||
Examples | ||
-------- | ||
>>> kelvin2fahrenheit(299.81666666666666) | ||
80.00000000000003 | ||
>>> kelvin2fahrenheit(300.2055555555555) | ||
80.69999999999997 | ||
Formula | ||
------- | ||
fahrenheit = (kelvin - 273.15) * 9/5 + 32 | ||
""" | ||
|
||
fahrenheit = (kelvin - 273.15) * 9.0/5.0 + 32 | ||
return fahrenheit |
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