設計一個求直角三角形斜邊長的函數(兩條直角邊為參數,求最長邊) 如果直角邊邊長分分別為3和4,那么返回的結果應該像這樣:
The right triangle third side's length is 5.0
def Pythagorean_theorem(a,b):
return 'The right triangle third side\'s length is {}'.format((a**2 + b**2)**(1/2))
#等價於a的平方與b的平方的1/2次方 (給斜邊開根)
print(Pythagorean_theorem(3,4)) #調用函數並打印結果