I'm currently working on the Mapping Software problem in the Tuple Unpacking lesson in the Python Data Structures course on SoloLearn. I ran my code in my own IDE and it came out to what I think is correct but the test case in SoloLearn says I'm wrong and their answer is hidden so I have no idea if I'm even close. I've had trouble finding the answer to it searching the interwebs. Here's the problem and my code.
You are working on a mapping software. The map is stored as a list of points, where each item is represented as a tuple, containing the X and Y coordinates of the point. You need to calculate and output the distance to the closest point from the point (0, 0). To calculate the distance of the point (x, y) from (0, 0), use the following formula: √x²+y²
Code:
import math
points = [
(12, 55),
(880, 123),
(64, 64),
(190, 1024),
(77, 33),
(42, 11),
(0, 90)
]
distances = []
for (x, y) in points:
z = math.sqrt(((x ** 2) - 0 + ((y ** 2) - 0)))
distances.append(z)
print(min(distances))
Output:
43.41658669218482
I feel like it has something to do with rounding or something small like that but I'm not sure. Can anybody help me. Thanks in advance.