Roman Numerals

4.1.0 · active · verified Thu Apr 09

The `roman-numerals` library provides utilities to manipulate well-formed Roman numerals, including converting between integers and Roman numeral strings. The current version is 4.1.0, and it generally sees major releases annually with minor updates as needed.

Warnings

Install

Imports

Quickstart

Demonstrates converting integers to Roman numerals and vice-versa using both the `Roman` class and the utility functions `to_roman` and `from_roman`.

from roman_numerals import Roman, to_roman, from_roman

# Using the Roman class
roman_four = Roman(integer=4)
print(f"Roman(integer=4): {roman_four} (integer: {roman_four.integer})")

roman_ninety = Roman(string='XC')
print(f"Roman(string='XC'): {roman_ninety} (integer: {roman_ninety.integer})")

# Using direct functions
converted_to_roman = to_roman(1994)
print(f"to_roman(1994): {converted_to_roman}")

converted_from_roman = from_roman('MCMXCIV')
print(f"from_roman('MCMXCIV'): {converted_from_roman}")

view raw JSON →