Skip to main content

A unit conversion library for time, mass, length, temperature, and more

Project description

# Converter 📦

**Cnverter_machine** is a lightweight and user-friendly Python library for converting between various units of measurement.  
It supports conversions across multiple categories including:

- ✅ Time (`s`, `min`, `h`, `day`, `week`, `month`, `year`)
- ✅ Mass (`mg`, `g`, `kg`, `t`, `lb`)
- ✅ Length (`mm`, `cm`, `dm`,`m`, `km`, `in`, `ft`, `yd`, `mi`)
- ✅ Area (`mm^2`, `cm^2`, `dm^2`, `m^2`, `km^2`, `ha`, `mi^2`, `ft^2`, `in^2`, `yd^2`)
- ✅ Volume (`mm^3`, `cm^3`, `dm^3`, `m^3`, `km^3`, `ft^3`, `in^3`, `yd^3`, `l`, `ml`, `cl`, `dl`)
- ✅ Speed (`m/s`, `km/s`, `km/h`, `mph`, `fps`, `ips`, `Ma`, `c`)
- ✅ Temperature (`C`, `F`, `K`)
- ✅ Data (`b`, `B`, `KB`, `MB`, `GB`, `TB`, `PB`)

---

## 🔧 Installation

```bash
pip install converter

🚀 Usage

from converter import converter_mass

print(converter_mass(1000, 'g', 'kg'))  # Output: 1.0

from converter import converter_area

print(converter_area(1, 'cm^2', 'm^2'))  # Output: 0.0001

from converter import converter_data

print(converter_data(8, 'b', 'B'))  # Output: 1.0

📋 Supported Units

Length Meters (m) Kilometers (km) Centimeters (cm) Millimeters (mm) Nautical Miles (mi) Yards (yd) Feet (ft) Inches (in)

Mass Kilograms (kg) Grams (g) Milligrams (mg) Pounds (lb) Tons (t)

Volume Cubic millimeter (mm^3) Cubic centimeter (cm^3) Cubic decimeter (dm^3) Cubic meter (m^3) Cubic yard (yd^3) Cubic inch (in^3) Cubic foot (ft^3) Liter (L) Milliliter (mL) Centiliter (cL) Deciliter (dL)

Temperature Celsius (C) Fahrenheit (F) Kelvin (K)

Area Square millimeter (mm^2) Square centimeter (cm^2) Square decimeter (dm^2) Square Meters (m^2) Square Kilometers (km^2) Hectares (ha) Square mile (mi^2) Square yard (yd^2) Square Feet (ft^2) Square Inches (in^2)

Data Bit (b) Byte (B) Kilobyte (KB) Megabyte (MB) Gigabyte (GB) Terabyte (TB) Petabyte (PB)

Speed Meter per second (m/s) Kilometer per second (km/s) Kilometer per hour (km/h) Mile per hour (mph) Foot per hour (fps) Inch per hour (ips) Mach (Ma) Lightspeed (c)

Time Seconds (s) Minutes (min) Hours (h) Days (d) Weeks (wk) Years (yr)

📚 Documentation Each converter function follows the same pattern: converter_(value, from_unit, to_unit)

Where is one of:

  • mass, length, area, volume, time, temperature, speed, data

All units are case-sensitive and lowercase, except for:

  • 'B' for byte
  • 'C', 'F', 'K' for temperature
  • 'Ma' for Mach (speed)

⚠️ Note: Unit names are case-sensitive, meaning 'B' (Byte) is different from 'b' (bit), and 'C' (Celsius) is different from 'c' (speed of light).

✅ Testing

To run tests:

pytest tests/

⚠️ Error Handling If an invalid unit is passed, the function will raise a ValueError with a clear message.

📄 License This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

converter_machine-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

converter_machine-1.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file converter_machine-1.0.2.tar.gz.

File metadata

  • Download URL: converter_machine-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for converter_machine-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5f978e53e5a306f82f5cec82663ae2de923bc9427570df7627c19c2486b19ab8
MD5 bf6770ee097843f2ef9c2e59f022059b
BLAKE2b-256 4ff3c66d1092110fe5dd6501d8a1961ab03af1b96b3955e8890131f4ccfa9e1a

See more details on using hashes here.

File details

Details for the file converter_machine-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for converter_machine-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af616f9c103790f234df6d036d20a7e90840d7a7ff4649dfa01c025dd6d516f6
MD5 7b97392e5d76a113763aa1137cc8bc5e
BLAKE2b-256 630b607b5135dc8b91465c5149338b3671663632b12a2301f16cc0af5df150bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page