Question: Translate the MATLAB num_roman.m function from the MATLAB homework assignment 3 into Python. The function should be called num_roman.py that converts integers between 1 and

Translate the MATLAB num_roman.m function from the MATLAB homework assignment 3 into Python. The function should be called num_roman.py that converts integers between 1 and 3999 into Roman numerals. The input will be a scalar number and it should output a string that is the Roman numeral representation of the input number. The function should give a meaningful error message if the input is less than one. The function should truncate a fractional value to an integer. Different meaningful error messages should occur if you enter a value greater than 3999 or the value is not a scalar. If no input is entered it should return the Roman numeral for 2018. For legitimate values the function should build up a string as follows where x is the input: while (x>=1000) subtract 1000 from x and concatenate M to the string if (x>=900) subtract 900 from x and concatenate CM to the string if (x>=500) subtract 500 from x and concatenate D to the string if (x>=400) subtract 400 from x and concatenate CD to the string while (x>=100) subtract 100 from x and concatenate C to the string if (x>=90) subtract 90 from x and concatenate XC to the string if (x>=50) subtract 50 from x and concatenate L to the string if (x>=40) subtract 40 from x and concatenate XL to the string while (x>=10) subtract 10 from x and concatenate X to the string if (x>=9) subtract 9 from x and concatenate IX to the string if (x>=5) subtract 5 from x and concatenate V to the string if (x>=4) subtract 4 from x and concatenate IV to the string while (x>=1) subtract 1 from x and concatenate I to the string Concatenate means to add text to the end of a current string (no spaces!)

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!