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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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