.Arabic and Roman Numerals. Write a program (called q4.py) to convert between Arabic and Roman numerals. Roman numerals are based on seven symbols of different
.Arabic and Roman Numerals. Write a program (called q4.py) to convert between Arabic and Roman numerals. Roman numerals are based on seven symbols of different values: I = 1, V = 5, X = 10, L = 50,C = 100, D = 500, and M = 1000. If you need a refresher on Roman numerals, Wikipedia is a good place to start. The biggest differences between Roman and Arabic numerals are that Romans didn't have a symbol for zero and that numeral placement within a number can sometimes indicate subtraction rather than addition. Furthermore, Roman numerals range from I (1) to MMMCMXCIX (3999).Your program will consist of three user-defined functions: roman(),arabic(), and main(), which converts an Arabic number to Roman numerals, converts Roman numerals to an Arabic number, and drivesthe program, respectively. A skeleton of p3.py has been providedand consists of stub functions for roman() and arabic(). The codefor the main() function is provided for you. You will provide thecode for the roman() and arabic(). Your submitted program mustinclude the 3 functions described above. When entering the input,the user will be provided with a > prompt. At the prompt, theuser can enter 3 commands: roman(x), arabic(x), or quit(), where xis the Arabic number or Roman numerals to be converted. Forexample, if the user enters roman(56), then the program will outputLVI. If the user enters arabic(CCXXXIV), then the program willoutput 234. If the user enters quit(), the program terminates.Assume that the user will enter valid input. When the user typesRoman numerals, assume they are uppercase.
Example. > roman (56) LVI 1 2 3 4 MMMCMXCIX 5 6 3999 7 8 CCXXXIV 9 10 11 > roman (3999) > arabic (MMMCMXCIX ) > roman (234) > arabic (CCXXXIV ) 234 > quit ()
Step by Step Solution
3.58 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
import re def arabics romval I 1 V 5 X 10 L 50 C 100 D 500 M 1000 intval 0 for i in rangelens if i 0 ...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started