human
Pythagorean Triplet with given sum using single loop | Function to calculate the Pythagorean triplet in O ( n ).
Iterate a from 1 to N - 1..
Calculate value of b.
The value of c = n - a - b.
Driver code.
Function call"
How can the above be solved in Python?

Write me a code to pythagorean Triplet with given sum using single loop and the other steps required?
assistant
#Here is code to pythagorean Triplet with given sum using single loop and the other steps required.
 def PythagoreanTriplet ( n ) :
	flag = 0
	for a in range ( 1 , n , 1 ) :
		b = ( n * n - 2 * n * a ) // ( 2 * n - 2 * a )
		c = n - a - b
		if ( a * a + b * b == c * c and b > 0 and c > 0 ) :
			print ( a , b , c )
			flag = 1
			break
	if ( flag == 0 ) :
		print ( " - 1" )
	return
if __name__ == ' _ _ main _ _ ' :
	N = 12
	PythagoreanTriplet ( N )