CPS 111: Introduction to Computational Thinking Homework 3 (20 points) Handed out: April 2nd, 2021 (Thursday) Due: 11:59 PM EST April 5th, 2021 (Monday) Late submissions accepted with penalty until...

No import re. , only using the define, split, find method.


CPS 111: Introduction to Computational Thinking Homework 3 (20 points) Handed out: April 2nd, 2021 (Thursday) Due: 11:59 PM EST April 5th, 2021 (Monday) Late submissions accepted with penalty until 11:59 PM EST April 6th If you run into trouble or have questions, arrange to meet with me or a tutor! Before you submit: • Please review the homework guidelines. Ensure that your code conforms to the style expectations set out therein. • Read the assignment very carefully to ensure that you have followed all instructions and satisfied all requirements. • When you’re ready to submit, create a zip file named like this: firstnamelastnameHWX.zip (with your username and replacing the X with the assignment number) that contains a directory named firstnamelastnameHWX, which contains all of your .py files. Make sure you have the entire directory in the zip archive, not just the files inside. • Ensure that you have cited any and all sources of help that you received via comments in your program. Such comments should be placed near the code that you received help on. For help that you have given to others, please include comments indicating that at the top of your program. The more context and information you provide the better. • Make sure to thoroughly test all of your programs before you submit your code. 1. For this problem you will write a very basic equation solver. Place all code in a file called eqn.py. Careful application of the computational problem solving approach, especially planning before coding, is going to be critical to solving this problem without writing tons of unnecessary code. Here are some comments regarding the implementation. a) Equations will be of the general form: operand + operand = answer or operand - operand = answer with either of the operands or the answer set to X. Here are some examples 1.X + 3 = 15 2.25 – 3 = X 3. 12 + X = 610 Your program should ask the user to type in an equation. Note: In order for your program to be robust, users may input equations (as a string) with space(s) or no space, variable names in uppercase or lowercase, and numbers in single, double, or multiple digits. Your program should still be able to handle and solve them correctly. For example, the following equations should all work for your program. X + 19 = 100 12-x = 10 26 +x= 126 33 -12= x Hint: Your program may preprocess the input equation string and convert it into the format which is easy to process later. For example, your program may remove all spaces and convert all letters in uppercases. “X + 19 = 100” will become “X+19=100”. “26 +x= 126” will be “26+X=126”. b) You should assume that any numbers will be be non-negative integers. c) The goal at the end is to print out the value of X. d) In addition to a main function (which should handle the general interaction and printing of the answer), I suggest you write two additional functions, one for add, one for subtract, both of which calculates and returns the value of X. Think carefully about the function parameters. How many? What are they?
Apr 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here