Advertisement
Guest User

Roman to Arabic from 1 to 40 million

a guest
Mar 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. numerals = [
  2.     ("Y", 10000000),
  3.     ("QY", 9000000),
  4.     ("Z", 5000000),
  5.     ("QZ", 4000000),
  6.     ("Q", 1000000),
  7.     ("UQ", 900000),
  8.     ("E", 500000),
  9.     ("UE", 400000),
  10.     ("U", 100000),
  11.     ("PU", 90000),
  12.     ("K", 50000),
  13.     ("PK", 40000),
  14.     ("P", 10000),
  15.     ("MP", 9000),
  16.     ("A", 5000),
  17.     ("MA", 4000),
  18.     ("M", 1000),
  19.     ("CM", 900),
  20.     ("D", 500),
  21.     ("CD", 400),
  22.     ("C", 100),
  23.     ("XC", 90),
  24.     ("L", 50),
  25.     ("XL", 40),
  26.     ("X", 10),
  27.     ("IX", 9),
  28.     ("V", 5),
  29.     ("IV", 4),
  30.     ("I", 1)
  31. ]
  32.  
  33. int_value = int(raw_input("Enter an integer value: "))
  34. output = ""
  35. for letter, value in numerals:
  36.         output += (int_value / value) * letter
  37.         int_value -= (int_value / value) * value
  38.  
  39. print output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement