-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)
4

1 回答 1

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')
于 2021-06-18T16:40:32.030 回答