Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print poly.index(element), element, finalResult
- YOUR CODE:
- `0 3.0 3.0`
- `1 4.0 -33.0`
- `1 4.0 -69.0`
- `3 2.0 -1527.0`
- `4 0.0 -1527.0`
- `-1527.0`
- MY CODE:
- `0 3.0 3.0`
- `1 4.0 -33.0`
- `2 4.0 291.0`
- `3 2.0 -1167.0`
- `4 0.0 -1167.0`
- `-1167.0`
- Since elements at index 1 and 2 are same, your code doesn't increment the index.
- Use this code:
- def evaluatePoly(poly, x):
- value = 0
- for index in range(0, len(poly)):
- value += (poly[index] * (x ** index))
- return float(value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement