Debugging Activity
Function Problem 2
As the crow flies
Suppose you have the coordinates of two points on a plane. To figure out the straight line distance between these points, you can apply Pathagorean's theorem to calculate the value.
For example, the distance between (-6 , 4) and (6 , -3) - line c on the following graphic:
Can be calculated as XXXXX by determining a has a length of 7, b has a length of 12, and when you use Pythagorean's theorem:
You find that
c2 = 72 + 122 = 49 + 144 = 193
so
c = sqrt( c2 ) = sqrt( 193 ) ≈ 13.89
Write a Python function that conforms to the following
- Function Name
- straightlineDistance()
- Parameters
- The x and y values of point 1
- The x and y values of point 2
- Return value
- The straight line distance (hypotenuse) between the two points.
- Example(s)
- Special Instructions
- You should not round the results in any manner
Consider the following function to solve this problem
I see at least three errors in this solution - two are syntax errors that will prevent it from saving/loading properly. The third is a logic error that means you get the wrong answer if you fix the first two things. Try to idenfity the errors.
You can watch the appropriate code-walkthrough video to see how I would answer this question.