human
Count pairs whose products exist in array | Returns count of pairs whose product exists in arr [ ].
Create an empty hash - set that store all array element.
Insert all array element into set.
Generate all pairs and check is exist in ' Hash ' or not.
if product exists in set then we increment count by 1.
return count of pairs whose product exist in array.
Driver Code"
How can the above be solved in Python?

What is a code to count pairs whose products exist in array and the other steps required?
assistant
#Here is code to count pairs whose products exist in array and the other steps required.
 def countPairs ( arr , n ) :
	result = 0
	Hash = set ( )
	for i in range ( n ) :
		Hash . add ( arr [ i ] )
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			product = arr [ i ] * arr [ j ]
			if product in ( Hash ) :
				result += 1
	return result
if __name__ == ' _ _ main _ _ ' :
	arr = [ 6 , 2 , 4 , 12 , 5 , 3 ]
	n = len ( arr )
	print ( countPairs ( arr , n ) )