By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

I need to take my list from MAP and make them 4 decimal places

P: 1
My List that comes from my MAP function I need to get to 4 decimal places

Expand|Select|Wrap|Line Numbers
  1. '''
  2. a = [5,4,6,8,9,12]
  3. b = [3,5,3,7,4,10]
  4. c = [4,7,7,4,10,14]
  5.  
  6.  
  7. #Gets S List
  8. hlist = map(add,a,b)
  9. h2list = map(add,hlist,c)
  10. twolist = [2,2,2,2,2,2]
  11. s = map(truediv,h2list,twolist)
  12.  
  13.  
  14. sqrtlist = [0.5,0.5,0.5,0.5,0.5,0.5]    
  15. sa = map(sub,s,a) # (s-a)
  16. sb = map(sub,s,b) # (s-b)
  17. sc = map(sub,s,c) # (s-c)
  18. sasb = map(mul,sa,sb) # (s-a)*(s-b)
  19. sall = map(mul,sasb,sc) # (s-a)*(s-b)*(s-c)
  20. x = map(mul,s,sall) # Multiplies inside by s
  21.  
  22. def square(x):
  23.     return x**0.5
  24.  
  25. A = map(square,x)
  26.  
  27.  
  28. AA = map(lambda x: x**0.5,x)
  29. '''
  30. """
  31. #OUTPUT
  32. AA list
  33. [6.0, 9.797958971132712, 8.94427190999916, 13.997767679169419, 17.984368212422698, 58.787753826796276]
  34.  
  35. [6.0, 8.0, 8.0, 9.5, 11.5, 18.0]
  36. """
  37.  
Thats my current code, minus some things. The numbers are correct I just need to to be rounded
Mar 15 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.