mamweb/seminar/utils.py
2015-05-14 00:49:20 +02:00

12 lines
302 B
Python

# -*- coding: utf-8 -*-
def roman(num):
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
res = ""
for i, n in zip(ints, nums):
res += n * (num // i)
num %= i
return res