I have these problems about polynomials and I've spent about 4 hours on this, but I just can't get it. I'm new to Python and programming and I've tried working it out on paper, but I just don't know.
Write and test a Python function
negate(p)
that negates the polynomial represented by the list of its coeffeicientsp
and returns a new polynomial (represented as a list). In other words, write a function that makes the list of numbers negative.Write a Python function
eval_polynomial(p, x)
that returns the value ofP(x)
, whereP
is the polynomial represented by the list of its coefficientsp
. For example,eval_polynomial([1, 0, 3], 2)
should return 1*2^2 + 0*2 + 3 = 7. Use a single while loop.Write and test a function
multiply_by_one_term(p, a, k)
that multiplies a given polynomialp
, represented by a list of coefficients, byax^k
and returns the product as a new list.
I would really appreciate it if someone could help me.
1 * 2 ** 2 + 0 * 2 ** 1 + 3 * 2 ** 0
in python... – Unspotted