Skip to main content

Effortlessly convert decimal numbers to Roman numerals in Python.

Project description

RomanPy

RomanPy is a Python library that provides a simple and efficient way to convert decimal numbers to Roman numerals. With its user-friendly interface, you can easily integrate this library into your Python projects and take advantage of its features to convert numerals in a matter of seconds.

Installation

To install RomanPy, you can use pip:

pip install RomanPy

This library has no dependencies and is compatible with Python 3.

Usage

To use RomanPy, you need to import the roman function:

from roman import roman

Then, you can convert decimal numbers to Roman numerals:

print(roman(207)) # CCVII

ASCII and unicode variants of the Roman numerals are supported in both lower- and uppercase, using the conventional API known from str:

numeral = roman(1776)

numeral = numeral.encode("ascii") # default
numeral = numeral.upper() # default

print(numeral) # MDCCLXXVI (default)

numeral = numeral.lower()

print(numeral) # mdcclxxvi

numeral = numeral.encode("unicode")
numeral = numeral.upper()

print(numeral) # ⅯⅮⅭⅭⅬⅩⅩⅥ

numeral = numeral.lower()

print(numeral) # ⅿⅾⅽⅽⅼⅹⅹⅵ

RomanPy also allows you to do simple arithmatic with roman numerals:

print(roman(100) + roman(60)) # CLX
print(roman(45) - roman(7)) # XXXIX
print(roman(533) * roman(2)) # MLXVI
print(roman(2460) / roman(10)) # CCXLVI

One hand of these operations is also allowed to be an integer:

print(100 + roman(60)) # CLX
print(roman(45) - 7) # XXXIX
print(roman(533) * 2) # MLXVI
print(2460 / roman(10)) # CCXLVI

Equality can be determined for other Roman numerals, integers and strings:

print(roman(335) == roman(335)) # True
print(roman(24) == 24) # True
print(roman(1954) == "MCMLIV") # True

Contributing

If you find any bugs or issues with RomanPy, please feel free to submit an issue on our GitLab page. We welcome any contributions or suggestions to improve this library.

License

RomanPy is released under the GPLv3 license. See LICENSE for details.

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

RomanPy-1.0.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

RomanPy-1.0.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file RomanPy-1.0.0.tar.gz.

File metadata

  • Download URL: RomanPy-1.0.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for RomanPy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3a5f9b6b4411578fd27c27d3655faf0149d6c8941aa5f94f77fe8c02aa31b6cb
MD5 fea9c2e0bafe9cb6f4a657a6d87d3b6b
BLAKE2b-256 77b2ac0b1cc06b7a5991fca32335580e42c0c1c84a316eb63decf636a01a5126

See more details on using hashes here.

File details

Details for the file RomanPy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: RomanPy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for RomanPy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9a2e2cab0b2e391c5805c8a61a2bf25d5045841523d14b5c453a7827efaccd8
MD5 5a22364cae5c86fdf73c62aac1ed8875
BLAKE2b-256 d2b60b61f16f2309dc37c283cc131b13034f3e2cff072e888c2cb2716be30f3a

See more details on using hashes here.

Supported by

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