0
Help me fix the python code below
def hypotenuse(leg1, leg2): #our function takes two arguments the leg 1 and leg 2 return( leg1**2 +leg 2**2)**(1/2) #according to the pythagorus theorem hypotenuse is equal to the square root of the sum of the squared legs print ("Test number 1, triangle with legs 3 and 4, hypotenuse is:," hypotenuse(3,4) ) #prints the call for triangle with legs 3 and 4 print ("Test number 2, triangle with legs 8 and 9, hypotenuse is:," + hypotenuse(8,9) ) #prints the call for triangle with legs 8 and 9 print ("Test number 3, triangle with legs 12 and 15, hypotenuse is:," + hypotenuse(12,15) )
2 Answers
+ 2
Your function returns a float value and it cannt be added in string using + operator in python ( other language supports it ) so remove + and use "," over there
+ 2
Besides äžčâšă©Ú©ć»Ÿ's answer, also remove the spurious space from +leg 2**2.