Advertisement
Mary_99

integer to roman

Mar 7th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. print("Conversion from arabic to roman notation")
  2.  
  3. class ConvertionSecond:
  4.     def convertionFunctionSecond(self, s:int)-> str:
  5.         arabicValues = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
  6.         romanValues = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I']
  7.         result = ''
  8.         for i in range(0, len(arabicValues)):
  9.             while s >= arabicValues[i]:
  10.                 s -= arabicValues[i]
  11.                 result += romanValues[i]
  12.         return result
  13. print(ConvertionSecond().convertionFunctionSecond(45))
  14. print(ConvertionSecond().convertionFunctionSecond(145))
  15. print(ConvertionSecond().convertionFunctionSecond(1999))
  16. print(ConvertionSecond().convertionFunctionSecond(2009))
  17. print(ConvertionSecond().convertionFunctionSecond(333))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement