Question: Problem 1 : Multiplication of Polynomial Texts ( hw 0 _ p 1 . py ) In mathematics, a polynomial is an expression consisting of

Problem 1: Multiplication of Polynomial Texts (hw0_p1.py )
In mathematics, a polynomial is an expression consisting of variables and coefficients, that involves
only the operations of addition, subtraction, multiplication, and non-negative integer exponents of
variables. An example of a polynomial of a single variable x, is x2-4x+7. An example in three
variables is x3+2x5YZ2-YZ+1.
In this homework, your task is to write a program to allow a text-version multiplication of multiple
polynomials. Specifically, the user is allowed to input a string that represents the multiplication of
several polynomials. Then you program needs to generate the string of the resulting polynomials.
The input and output polynomial strings need to follow the following rules.
(1)n*x means n is the coefficient, x is the variable, and n is the coefficient of variable x. In
other words, coefficients are always placed before variables.
(2)xn represents xn, where x is the variable, and n is the exponent of x. That said,
exponents are always placed after variables.
(3) Polynomials with the same variables need to be put together by adding their coefficients, for
example, 5*xY2+3*xY2 should be 8*xY2.
Note that you can use only pure Python, i.e., you cannot use any package.
Sample Input/Output:
c: \Python35\workspace\20181 hw3>hw3_p2.py
Input the polynomials: (x+2Y)(2x2-Y2+Z)
Output Result: 2x3-xY2+xZ+4x2Y-2Y3+2YZ
C: \Py thon353 workspace \2018\hw3>hw3
p2.py
Input the polynomials: (2x+3Y+4Z)(xY2+x2Y+Z2)
Dutput Result: 5x2Y2+2x3Y+2xZ2+3xY3+3YZ2+4xY2Z+4x2YZ+4Z3
C: \Python35\workspace\2018\hw3>hw3
p2.py
Input the polynomials: (A+2B2)(B+3C3)(2A+B+C)
Output Result: 2A2B+AB2+ABC+6AC32+3ABC3+3AC4+4AB3+2B4+2B3C+12ABC32+6BC33+6B2C4
FAQ
The polynomials entered in the first question need to be enclosed in "()" eg (X)(X^2+Y^3)
Problem 1 : Multiplication of Polynomial Texts (

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 Programming Questions!