I run this code over and over, but there are some tests where the result’s output won’t match the expected result, Is there sth I am not considering here?

1. Do you understand what the test is doing?
2. Do you understand what the test is expecting and why?
3. Do you understand what your code returns and how it differs?
4. Do you understand why your code is returning what it returns?

Well I understand that it tries to calculate the score when the dart is “on the inner circle”, “near the center” and “just within the inner circle”.

I know what the test is expecting but I’m not sure if I know why.

Yes, but the thing I don’t understand which I think questions the way I wrote the code is how the calculated distance can determine the score, I mean I don’t understand what the unit is.

The first test calls your function with values 0, -1 and expects to get back 10. It expects 10 because the location 0, -1 is within the 1 unit inner circle.

The test gets back 5 and complains that it is not the expected value, 10.

What the unit is (cm, inches, meters) doesn’t especially matter.

The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1.

The distance can be computed using the Pythagorean Theorem which you are doing correctly.