human
Find the closest Fraction to given fraction having minimum absolute difference | Function to find the absolute value of x.
Function to find the fraction with minimum absolute difference.
Initialize the answer variables.
Iterate over the range.
Nearest fraction.
x / y - d / i < x / y - A / B ( B * x - y * A ) * ( i * y ) > ( i * x - y * d ) * ( B * y ).
Check for d + 1.
Print the answer.
Driver Code"
How can the above be solved in Python?

=====
Give me a code to find the closest Fraction to given fraction having minimum absolute difference and the other steps required?
assistant
#Here is code to find the closest Fraction to given fraction having minimum absolute difference and the other steps required.
 def ABS ( x ) :
	return max ( x , - x )
def findFraction ( x , y , n ) :
	A = - 1
	B = - 1
	for i in range ( 1 , n + 1 ) :
		d = ( i * x ) // y
		if ( d >= 0 and ( A == - 1 or ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) :
			A = d
			B = i
		d += 1
		if ( d >= 0 and ( A == - 1 or ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) :
			A = d
			B = i
	print ( str ( A ) + " / " + str ( B ) )
if __name__ == ' _ _ main _ _ ' :
	x = 3
	y = 7
	n = 6
	findFraction ( x , y , n )