Python
As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments.
Include all of the following:
Given below is the code in Python:
import math # math library is reuired for the sqrt (squareroot function)
def hypotenuse(x,y): # function declaration where x and y
are the parameters passed
return math.sqrt(x*x+y*y) # return squareroot of x^2 + y^2
# Driver code
print(hypotenuse(3,4)) # function call with 3 and 4 as the
parameters
Get Answers For Free
Most questions answered within 1 hours.