Hypotenuse finder in python (help) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hypotenuse finder in python (help)

I’m new to coding so I figured I’d start on python. I’ve tried using what I’ve learned about functions to write a program that will find the hypotenuse of any triangle. All you have to do is give it the side lengths and it will tell you the hypotenuse of that triangle. If someone could look at it and tell me where I went wrong I would be very appreciative

1st Apr 2018, 2:31 AM
James Hunter
James Hunter - avatar
2 Answers
+ 3
""" You made a lot of mistake in your short code... Fixed and worked code would be: """ import math def C_squared(a,b): return math.sqrt(a**2+b**2) i1 = int(input()) i2 = int(input()) C=C_squared(i1,i2) print("hypotnuse is "+str(C)) # Anyway, feel free to ask much more help on specific topic (that's too long to explicit each of your mistake ^^)
1st Apr 2018, 2:44 AM
visph
visph - avatar
0
Thanks so much! I guess I’ve still got some learning to do I’m curious what a simple thought process would be for writing calculator codes. Is it simply 1. Define function 2. Create variables 3. Return input to function 4.Print answer?
1st Apr 2018, 3:50 AM
James Hunter
James Hunter - avatar