Guest User

Untitled

a guest
Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. from fractions import Fraction
  2. a = float('1') / float('4')
  3. b = '1/4'.split('/')
  4.  
  5.  
  6. def series_sum(n):
  7. if n == 0:
  8. return "0.00"
  9. else:
  10. series = [Fraction(float(1) / float((3 * x) - 2)) for x in range(1, n+1)]
  11. total = round(0, 2)
  12. for item in series:
  13. total += float(item)
  14. return "{0:.2f}".format(total)
  15.  
  16. fractions = [Fraction(float(1) / float((3 * x) - 2)) for x in range(1, 10)]
  17.  
  18. series_sum(98)
  19. # print fractions
  20. # print "{0:.2f}".format(float(fractions[2]))
Add Comment
Please, Sign In to add comment