Skip to content
Advertisement

Add Two Polynomials Python Program

In this code there are four test cases. 1st and 2nd and 4th test cases are camed successfully but 3rd test case was not getting expected output. Please help me I got 12x^4 + 9x^3 – 5x^2x – 1 as output in 3rd test case but expected output is 12x^4 + 9x^3 – 5x^2 – x – 1

For Add two polynomials program question and 4 test cases Inputs and Outputs see below url

https://drive.google.com/file/d/1dEzy0tHPt-dveknUMw8ml85IARaoLcsE/view?usp=sharing

The above link contains Add two polynomials Question, 4 test cases and Inputs and Outputs

JavaScript

Advertisement

Answer

Your problem is occurred at:

JavaScript

you should change the code to print (f' - x',end='')

In addition, your use a little too much tab, I suggest you to rearrange the code like:

JavaScript

this is much clearly

new edit for 5th input:

because your are lack of judging the first term in coefficient < 0 condition, so the code should be:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement