-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteger2roman.py
More file actions
executable file
·60 lines (44 loc) · 978 Bytes
/
Copy pathinteger2roman.py
File metadata and controls
executable file
·60 lines (44 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
romans = {
1000: "M",
900: "CM",
500: "D",
400: "CD",
100: "C",
90: "XC",
50: "L",
40: "XL",
10: "X",
9: "IX",
5: "V",
4: "IV",
1: "I"
}
def roman(num):
result = ""
for key, value in romans.items():
if num in romans:
result += romans[num]
return result
mod = num//key
if mod >= 1:
result += mod*value
num = num%key
return result
# result = ""
# for key, value in romans.items():
# if num in romans:
# result += romans[num]
# return result
# mod = num//key
# if mod >= 1:
# result += mod*value
# num = num%key
# return result
def queryUser():
while True:
number = input("Type a number: ")
if number == "":
break
else:
print(roman(int(number)))
queryUser()