Question: Python 3.6- Here's the source code for a program that converts given integer to its roman numeral equivalent (shown below). I want to ask user

Python 3.6-

Here's the source code for a program that converts given integer to its roman numeral equivalent (shown below). I want to ask user "Do you want to try more numbers (y)? If user enters yes, then the program should continue converting integer to Roman numeral. Include that in indented source code and provide screenshot of output. Thanks.

Python 3.6- Here's the source code for a program that converts given

# dict subclass that remembers the order entries that were added from collections import OrderedDict 8 def write roman (num): To create an ordered dictionary that converts given integer to its Roman numeral equivalent Test data: input: N/A output:N/A Params: num (integer) return: N/A list # iterate downwards the roman -orderedDict() roman [ 1000] = "M" roman [ 900] = "CM" roman [ 500] = "D" roman [ 400] "CD" roman [ 100] = "C" roman [90] = "XC" roman [ 50]"L" roman [40] "XL " roman [ 10] = "X" roman [9] = "IX" roman [5]"V" roman [ 4 ] = " IV" roman [ 1] = "1" 16 28 def roman_num (num): 34 for r in roman.keys(): # generate matches using recursion x, y divmod (num, r) yield roman[r]x num (r *x) if (num 0) roman num(num) else: 42 break # generates a text string return(" ".join ([a for a in roman num (num) ])) 46 def main(): # allows user to enter number into keyboard num - input( 'Enter a number:) try: 50 numint (num) print (write_roman (num)) # if user enters invalid data then the try block is skipped and except clause is executed except: print('Enter valid data') 56 main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!