10x^6+3x^5+4x^+4
9x^6+2x^4+2x+5
1)could you please propose a suitable data structure to store above ploynomials.
2) and, how to add & multiply them using python codes.
10x^6+3x^5+4x^+4
9x^6+2x^4+2x+5
1)could you please propose a suitable data structure to store above ploynomials.
2) and, how to add & multiply them using python codes.
Jump to PostIt looks like homework. Did you try to add the polynomials in a python console ?
It looks like homework. Did you try to add the polynomials in a python console ?
As Gribouilis said, there is only so much we can suggest without doing the work for you. As for data structures, there are three options I can recommend, in order from least preferred to most:
I would probably choose version two, as it probably would be the easiest for handling the arithmetic. I would wrap that representation in a Polynomial
class to make the arithmetic operations part of the whole structure.
9x^6+2x^4+2x+5
would be ...9*x**6 + 2*x**4 + 2*x + 5
You could store it as a string and design a little parser to pick it appart.
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.