daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print poly.index(element), element, finalResult
  2.  
  3. YOUR CODE:
  4. `0 3.0 3.0`
  5. `1 4.0 -33.0`
  6. `1 4.0 -69.0`
  7. `3 2.0 -1527.0`
  8. `4 0.0 -1527.0`
  9. `-1527.0`
  10.  
  11.  
  12. MY CODE:
  13. `0 3.0 3.0`
  14. `1 4.0 -33.0`
  15. `2 4.0 291.0`
  16. `3 2.0 -1167.0`
  17. `4 0.0 -1167.0`
  18. `-1167.0`
  19.  
  20. Since elements at index 1 and 2 are same, your code doesn't increment the index.
  21. Use this code:
  22.  
  23. def evaluatePoly(poly, x):
  24.     value = 0
  25.     for index in range(0, len(poly)):
  26.         value += (poly[index] * (x ** index))
  27.     return float(value)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top