My task is to calculate the distance between the rectangle and the 0/0 point in the coordinate system and print a specific answer. If it approaches 100 m (the unit is in meters, 1 unit = 1 meter), it should print 100 m, if the distance is <200 m, print 101 m ...
I found out that I can use the Pythagorean theorem to get the distance between two coordinates. I implemented it in my program (in Python), but I have some problems with the exit.
Try an example. A rectangle with coordinates (-400,200); (-300, 200); (-300, 300); (-400, 300) is 360 meters from the point (0/0). The correct exit will be "103 m".
Someone asked something like this before, and they said: you need to divide the distance to 100 and add it to "10 {}".
print("10{}m".format(distance
Actually, this works for everything below 1000. If the coordinates are (-4000,2000); (-3000, 2000); (-3000, 3000); (-4000, 3000), the correct distance will be “3605 m”, and it should output “136 m”.
Hope you can understand my question / question!
source share