Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Same issue; tried both of these approaches (round & float).
Yeah, that's the point. We want to get the right answer as we make in general mathematic, regardless of the Python specification.
What's the reasoning behind this test? It clearly differs from the definition of "rounding" othe standard library, and there's no clear definition on the kata description that entails it.
I wonder if this test should be commented by default and labeled as optional?
Compliance to this particular test is not required to pass the kata.
Having the same code fail the supplied test cases but succeed the kata's test cases can be confusing/frustrating for beginners.
don't know how about you, but for me even round(n,2) didn't work...
despite the solution using round(n,2) passed obviously
Good idea! But now that that test has been added, most of the already accepted answers should not work.
Added the test case.
This comment is hidden because it contains spoiler information about the solution
It works exactly as expected. Per the python spec:
Note The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. See Floating Point Arithmetic: Issues and Limitations for more information.