Question: Python Write a function moronic calc() that takes a string consisting of a mathematical expression written in Mo- ronicnumerals,suchasFFSSEI - FIIE,andreturnsthevalueoftheexpressioninMoronicnumerals. In the argument you

Python

Python Write a function moronic calc() that takes a string consisting of

Write a function moronic calc() that takes a string consisting of a mathematical expression written in Mo- ronicnumerals,suchasFFSSEI - FIIE,andreturnsthevalueoftheexpressioninMoronicnumerals.

In the argument you may assume that there is always exactly one space after the first operand, followed by an operator, followed by a space, followed by the second operand. Negation of numbers is also allowed, but with some limitations mentioned below. If a number is negated, then the negation symbol appears immediately to the left of the leftmost numeral.

Your calculator must support the following mathematical operators:

a mathematical expression written in Mo- ronicnumerals,suchasFFSSEI - FIIE,andreturnsthevalueoftheexpressioninMoronicnumerals. In the argument

Important notes:

- Either or both operands could be negative, except for the exponent in an exponentiation operation, which you may assume is positive.

- You may assume that the result of an operation is in the range [3071, 3071], with the exception of zero.

- If the result is positive, do NOT include a + sign in front of it.

- Finally, you will want to have the moronic calc() functioncall your arabic2moronic() and moronic2arabic() functions as needed to help solve this problem. **(I posted two other questions for the arabic2moronic() and moronic2arabic() functions)**

you may assume that there is always exactly one space after the

 def moronic_calc(expression): return None 
 if __name__ == "__main__": 
 print('Testing moronic2arabic() for "FIE + SSSEIII": ' + str(moronic_calc('FIE + SSSEIII'))) print('Testing moronic2arabic() for "-SIE - -FSSSEIII": ' + str(moronic_calc('-SIE - -FSSSEIII'))) print('Testing moronic2arabic() for "-FSFEIII / EIII": ' + str(moronic_calc('-FSFEIII / EIII'))) print('Testing moronic2arabic() for "IIIII * EEEEEIII": ' + str(moronic_calc('IIIII * EEEEEIII'))) print('Testing moronic2arabic() for "-IIIII ^ III": ' + str(moronic_calc('-IIIII ^ III'))) 

You've heard of Roman numerals, but have you heard of Moronic numerals? Probably not because we've invented them for this homework assignment. Moronic numerals are similar to Roman numerals in that numbers are formed by combining symbols and adding the values In Moronic numerals, each numeral has a fixed value representing a power of 8 (rather than a power of 10 or half of a power of 10, as in Roman numerals) Symbol: I E S F Value: 1 3 64 512 Symbols are placed from left to right in order of value, starting with the largest. For example, FFFFSSSEEEEEllll s 2, 284 (512 x 4) (64 x 3) (8 x 5) (4 x 1) In a few specific cases, to avoid having six or more characters being repeated in succession (such as llllll or EEEEEE), subtractive notation is used, as in this table: Number 6 7 48 (64 2x 8) 56 (64 1x8) 384 (512 2x64) 448 (512-1x64) Notation: ILE DE EES SF ES SSF

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!