Converting Roman to Decimal in Python using gnboorse-rom module
Last Updated :
21 Apr, 2020
A gnboorse-rom module is that library of python which helps you convert roman numerals into decimal number and decimal number into roman numerals .It will do conversion of values upto 3999 both in roman numerals and decimal system .
Note: Following is the list of some unique Roman symbols with their corresponding decimal values.
SYMBOL VALUE
I -> 1
IV -> 4
V -> 5
IX -> 9
X -> 10
XL -> 40
L -> 50
XC -> 90
C -> 100
CD -> 400
D -> 500
CM -> 900
M -> 1000
A number in Roman Numerals is a string of these symbols written in descending order(e.g. M’s first, followed by D’s, etc.). However, in a few specific cases, to avoid four characters being repeated in succession (such as IIII or XXXX), subtractive notation is often used as follows:
- I placed before V or X indicates one less, so four is IV (one less than 5) and 9 is IX (one less than 10).
- X placed before L or C indicates ten less, so forty is XL (10 less than 50) and 90 is XC (ten less than a hundred).
- C placed before D or M indicates a hundred less, so four hundred is CD (a hundred less than five hundred) and nine hundred is CM (a hundred less than a thousand).
Installing Library
This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.
pip install gnboorse-rom
Functions of gnboorse-rom :
Note: For understanding of code behind the logic you can refer to GeeksforGeeks
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...