I have been trying to make a code which deduces whether a right-angled triangle is a pythagorean triplet or not. I have then tried to draw the triangle in turtle. However, when I try and get the degrees between the base and the hypotenuse, I get this:
TypeError: unsupported operand type(s) for *=: 'function' and 'float'
This is my code:
import math
isrightangled = int(input('is your triangle right-angled? enter 1 for no. if it is, press any other number'))
if isrightangled == 1:
print('your triangle is not a pythagorean triplet.')
else:
a = int(input('Please enter the perpendicular height of your triangle.'))
b = int(input('please enter the base length of your triangle.'))
apowerof2 = a * a
bpowerof2 = b * b
cpowerof2 = apowerof2 + bpowerof2
c = math.sqrt(cpowerof2)
degrees = int(math.degrees(math.atan(a/b)))
print(degrees)
cinput = int(input('Please enter the length of the hypotenuse of the triangle.'))
if c == cinput:
print ('your triangle is a pythagorean triplet')
from turtle import *
drawing_area = Screen()
drawing_area.setup(width=750, height=900)
shape('circle')
left(90)
forward(a * 100)
backward(a*100)
right(90)
forward(b*100)
left(degrees)
forward(c*100)
done()
else:
print ('your triangle is not a pythagorean triplet.')
Any help would be greatly appreciated!