I am using the follow code to calculate the hypotenuse and legs of a rectangle triangle. If any one of the 3 given values(a, b ou c) is "x", it would be to calculate other variables. But, when I run the code, I get the message bellow:
Traceback (most recent call last):
File "main.py", line 7, in <module>
quadradosA_B = int(b*b)+int(c*c)
TypeError: can't multiply sequence by non-int of type 'str'
Traceback (most recent call last):
File "main.py", line 7, in <module>
quadradosA_B = int(b*b)+int(c*c)
TypeError: can't multiply sequence by non-int of type 'str'
import math a = input('Informe a hipotenusa: ') b = input('Informe o Cateto A: ') c = input('Informe o Cateto B: ') if (a == 'x'): quadradosA_B = int(b*b)+int(c*c) hipotenusa = math.sqrt(quadradosA_B) print('A hipotenusa é: ', hipotenusa) elif (b == 'x'): quadradoCatetoB = int(a*a)-int(c*c) CatetoB = math.sqrt(quadradoCatetoB) print('Cateto B vale: ', CatetoB) elif (c == 'x'): quadradoCatetoC = int(a*a)-int(b*b) CatetoC = math.sqrt(quadradoCatetoC) print('Cateto C vale: ', CatetoC)