473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
0 1094

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

Similar topics

3
by: Brent Bortnick | last post by:
Does anyone know how to find out the number of decimal places a number has. I need this info so that i can round to 3 decimal places if the number has 3 decimal places or to 2 decimal places if...
6
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly...
2
by: Hank | last post by:
Hello, I am displaying numerical (single) values from a table into a list box using Access 2000. Although the format in the table is for three decimal places, the list box rounds all the columns...
5
by: GaryB | last post by:
I have a database field that is the product of a multiply in a sql statement and it sometimes has 5 or more decimal places. I want to truncate beyond the 2nd decimal place(###.##). I figured a...
4
by: Hank | last post by:
Hello, I'm running Access 2000. I would like to know if its possible to use VBA code to determine how many decimal places are specified for each table field. Currently I loop throught the...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
3
by: mattlightbourn | last post by:
Hi, I hope you're all well. I need to right justify some figures in a list box and the only way I seem to be able to do it is by using the number as text and doing something like this in a...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
5
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, I have a collection (an array for example) of decimal values. I need to round them and take care of the roundings. For example, if I have decimal a = 10.50m should became 10 and if
3
by: VivDenham | last post by:
Hi there I have a table - Projects - with 2 fields: Project ID (autonumber) and Project Name. I then have a 2nd table - Decorations Used - which contains 3 fields - Decorations Used Id; Project...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.