Q. Write a program to convert given number into equivalent roman number (store its value as string ).
You can understand by Watching video :-
 
    
  Answer :-
dec = [1000,900,500,400,100,90,50,40,10,9,5,4,1]
rom = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
n =  int (input ("Enter the number ="))
roman= " "
for i  in range (len(dec)):
    m = n //dec[i]
    for j in range (m):
        roman +=rom[i]
    n = n % dec [i]
print (roman)
Output :-
Enter the number =59
 LIX
>>> 
Enter the number =269
 CCLXIX
>>> 
Enter the number =999
 CMXCIX
>>> 
y use list in string que?
ReplyDeleteWhat you want to say.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )