* --Originally published at Programming*

In this quiz we have to ask the user for the coordinates of two points in the cartesian plane, and then, calculate the distance between them. Let’s see the code:

First we importh math because we need the square root then. Our function that will do the magic is call distance, and here is where we write the variables. Finally in this part we write what we want it return, that is the formula of distance between two points. You can find more information about this here: Distance Between 2 Points.

Now, the second part is just to ask the user for the inputs like floats. There will be 2x and 2y, one by each point. Finally, we print the result. Original instructions didn’t ask for this step, but I included it because I think it helps to see how it works. You can avoid to follow the instructions correctly if you prefer.

And this is how it runs:

Hope it helps