Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Steven Holcombe
499 PointsFloats & Currency question
So i see when you do the checkplease.py if you divide the 84.97 by 4 people you get a number that couldn't be easily paid. Is there a way to round to that $21.24 and drop the extra .0025 in the amount_due within python?
1 Answer
Steven Parker
243,253 PointsThere's an actual "round" function:
round(val + 0.005, 2)
The added half cent makes sure the value is always rounded up.
Steven Holcombe
499 PointsSteven Holcombe
499 PointsThanks for the reply but i have a question! what is the 2 in the function stand for?
Steven Parker
243,253 PointsSteven Parker
243,253 PointsThe 2nd argument is how much precision you want the rounding to produce. A "0"would give you whole numbers.