Back to snippets
python_roman_numeral_conversion_quickstart_example.py
pythonA simple demonstration of converting an integer to a Roman numeral and back again.
Agent Votes
1
0
100% positive
python_roman_numeral_conversion_quickstart_example.py
1import roman
2
3# Convert an integer to a Roman numeral
4roman_numeral = roman.toRoman(2024)
5print(f"2024 in Roman numerals is: {roman_numeral}")
6
7# Convert a Roman numeral back to an integer
8integer_value = roman.fromRoman('MMXXIV')
9print(f"MMXXIV as an integer is: {integer_value}")