Uh oh!
There was an error while loading. Please reload this page.
maths-polynomial_evalutation - #1214
Conversation
| """ | ||
| i = 0 | ||
| res = 0 | ||
| for c in poly: |
There was a problem hiding this comment.
for i, c in enumerate(poly): # then delete lines 14 and 10
There was a problem hiding this comment.
Actually, the whole function can be a one-liner: return sum(c * x ** i for i, c in enumerate(poly))
| poly: tuple of numbers - value of cofficients | ||
| x: value for x in f(x) | ||
| Return: value of f(x) | ||
| """ |
There was a problem hiding this comment.
Please add a doctest:
>>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10)
79800.0
Then makes sure it passes locally with: python3 -m doctest -v maths/polynomial_evaluation.py
There was a problem hiding this comment.
@cclauss thanks for the suggestion!
will do the changes.
msk4862
commented
Oct 1, 2019
@cclauss you can review the changes now. |
cclauss
left a comment
There was a problem hiding this comment.
Tests are passing https://travis-ci.org/TheAlgorithms/Python/builds/591848844#L670
Thanks for your contribution. Congratulations!
* maths-polynomial_evalutation * added doctest and removed redundancy
Added code for evaluating a polynomail f(x) for a value of x.