Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help do this in Python please ? Create a Python module: 1. Create a script named equation_parts.py 2. Create a function named is

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Can someone help do this in Python please?

Create a Python module: 1. Create a script named equation_parts.py 2. Create a function named is numeric a. It accepts a single character as a string. b. The function will check to see if the value is: i. a digit(0,1,2,3,4,5,6,7,8,9) ii. a decimal point C. If the character is valid, return True, if not return False. 3. Create a function named is_math_symbol a. It accepts a single character as a string. b. The function will check to see if the value is a valid operator: i. + iii. x iv. / V. vi. % c. If the character is valid, return True, if not return False. C. 4. Create a function named get_math answer a. It accepts a starting operand, an operator, and an ending operand each as strings. b. The function will convert the operands to floats. It will then perform the correct mathematical operation on the two operands based on the operator that was provided. d. The mathematical operations need to match what is in the table above. e. Return the answer of the operation. i. If not a valid Operator Operand1 Operand2 returns operator, return 0. 5 3 8.0 ii. Here are some 5 3 2.0 examples -> x 5 3 15.0 5 3 1.66666666666666667 Create a Python script: IN 5 3 1.0 % 5 3 2.0 1. Create a script named x 2.3 14.95 equation_parser.py 7.4 3 10.4 3.3 1.1 2.999999999999996 2. Create a function named 3 4 0.0 continue_loop a. It accepts nothing. b. Prompts the user to continue. c. The user can enter any of the following answers for opting whether or not to continue: 6.5 + i. Acceptable answers are: y, yes, n, no ii. These need be to handled case insensitive (case does not matter). 1. Use upper or lower() functions to help validate input. d. If the user enters any other than the than the values above, inform the user and continue to prompt the user until they enter a correct value. e. Returns a Boolean; true to continue, false to stop. i. Does not return until a valid answer is entered. 3. In the script, prompt the user for the equation to parse. 4. Iterate each character in the string and using the appropriate functions, check whether the character is a digit, operator, or space. a. If it is a digit, append the digit character (add to the end of) a string which will be the first operand. b. If it is a space or math symbol, stop appending to the first operand. C. If it was a symbol, store the symbol character. d. After the first operand has been stored, any following digits need to be added to a second operand. 5. When you have iterated every character, use the get_math_answer function to get the correct answer using the operator and operands. 6. Display equation and the user to the user nicely formatted. a. The displayed equation must have spaces around the operator even if the user's equation did not have them. b. You must use the string format method. "format string".format(a1, a2, ...) i. You must provide at least two arguments to be formatted using string.formato ii. This is the format that uses curly braces {} c. Your results do not have to look like mine, but you must use the format method off of the string object. 7. Continue until the user opts not to continue entering equations. Hints: Remember, code a little and test. Always keep a working program. For example, start with writing the code to just allow the user to enter a single equation and parsing it before adding the feature to continue until opting out. Functions specified in an assignment are the minimum. It is often easier to make additional functions to break up your code and make it easier to write. You can iterate a string by index or by letter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions