Re: Print result of function doesn't work

Torbjorn Svensson Diaz via Tutor <[email protected]> Mon, 22 Jul 2024 13:21:35 +0200
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
On 7/20/24 6:20 PM, Torbjorn Svensson Diaz via Tutor wrote:
> Hello, dear tutors!
>

Hello, dear tutors!

I've made it! Wohoo!

The following works.



import math


print("What is the length of the first leg of the triangle?")
leg1 = float(input())

print("What is the length of the second leg of the triangle?")
leg2 = float(input())

def hypotenuse(leg1, leg2):
     legs = leg1**2 + leg2**2
     result = math.sqrt(legs)
     return result

x = hypotenuse(leg1, leg2)
print(x)


It turns out I had to convert the input into a float as it's a string by 
default. Thanks for all your advice and guidance!

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor