-1

so i am a beginner and wanted to make an app using python to know the kind of the triangle using the sides, i wanted to use this rule (AC^2 = ab^2 + bc^2) but it says i can't square a string so i removed the function sqrt(), but then it says none instead of saying("the triangle is right angled")( i wanted to make it interactive)

#right angled= AC^2 = BC^2 + AB^2
#acute angled= AC^2 < BC^2 + AB^2
#obtuse angled= AC^2 > BC^2 + AB^2
side1 = input("the first side: ")
side2 = input("the second side: ")
side3 = input("the third side: ")
def sides_of_tri(side1, side2 , side3):
    if (side1) ==(side2) + (side3):
        print("the triangle is right angled")
sides_of_tri(side1, side2, side3)
ZIRUS
  • 5
  • 1
  • What exactly is your question? – mkrieger1 Jun 18 '21 at 16:10
  • In any case, you need to convert the user inputs to numbers, if you want to do any calculations with them. – mkrieger1 Jun 18 '21 at 16:11
  • maybe try that in a repl, so you can see live what you're doing e.g. https://gist.github.com/AD7six/c287d8c29687f14638283818155bbd93 - that should make clear why two 'numbers' added together are not the value you're expecting. Please self-answer when you solve it :) – AD7six Jun 18 '21 at 16:12
  • `input()` returns a string. "adding" strings concattenates them. you need to convert your string input into a number. See dupe. – Patrick Artner Jun 18 '21 at 16:12
  • Put your `sqrt` function back, and do `float(input("..."))` instead of `input("...")`. Before that, keep in mind that, say, `"4" + "4"` equals `"44"`, while `4 + 4` equals `8`. – keepAlive Jun 18 '21 at 16:17

1 Answers1

0
def side_squared(side):
    
    Sidesqd=float(side)*float(side);
    return Sidesqd;
    def triangle_type(hyp,prep,base):
        hypsqd=side_squared(hyp)
        prepsqd=side_squared(prep)
        basesqd=side_squared(base)
        
        if hypsqd==prepsqd+basesqd:
            print('Right Angled')
        elif hypsqd<prepsqd+basesqd:
            print('Acute Angled')
        else :
            print('Obtuse Angled')