Question: Write a function named distance that takes four parameters: the x - and y - coordinates of the first point, followed by the x -

Write a function named distance that takes four parameters: the x- and y-coordinates of the first point, followed by the x- and y-coordinates of the second point. It should return the distance between those two points, using the Pythagorean Theorem, for which you will need to import the mathLinks to an external site. module and use the math.sqrt() function.
Example1: d = distance(3,5,-1,2); Your function should return d =5
Example 2: d = distance(0,0,0,0); Your function should return d =0
2. Write a main function that will execute and call the distance function if the file is run as a script, but not if the file is imported into another file. Test it out by running it as a script and by creating another file that imports it and running that file as a script.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!