Aug-09-2020, 07:45 PM
From Wikipedia
https://en.wikipedia.org/wiki/Roman_numerals
Complete the code at (...) and you should be good to go.
:)
PS, of course it should be a class with converters, and the dictionary should be a class variable and etc. ...
https://en.wikipedia.org/wiki/Roman_numerals
Complete the code at (...) and you should be good to go.
:)
PS, of course it should be a class with converters, and the dictionary should be a class variable and etc. ...
def roman_numeral(n): dntor = { 3000:'MMM', 2000:'MM', 1000:'M', 900:'CM', 800:'DCCC', 700:'DCC', 600:'DC', 500:'D', 400:'CD', 300:'CCC', 200:'CC', 100:'C', 90:'XC', 80:'LXXX', 70:'LXX', 60:'LX', 50:'L', 40:'XL', 30:'XXX', 20:'XX', 10:'X', 9:'IX', 8:'VIII', 7:'VII', 6:'VI', 5:'V', 4:'IV', 3:'III', 2:'II', 1:'I', 0:'' } assert(0 < n < 4000) x = n%10 rs = dntor[x] n -= x #... assert(n==0) return rs