human
Count number of pairs with positive sum in an array | Returns number of pairs in arr [ 0. . n - 1 ] with positive sum.
Sort the array in increasing order.
Intialise result.
Intialise first and second pointer.
Till the pointers doesn 't converge   traverse array to   count the pairs .
If sum of arr [ i ] && arr [ j ] > 0 , then the count of pairs with positive sum is the difference between the two pointers.
Increase the count.
Driver 's Code .
Function call to count the pairs with positive sum"
How can the above be solved in Python?

What is a code to count number of pairs with positive sum in an array and the other steps required?
assistant
#Here is code to count number of pairs with positive sum in an array and the other steps required.
 def CountPairs ( arr , n ) :
	arr . sort ( )
	count = 0 ;
	l = 0 ; r = n - 1 ;
	while ( l < r ) :
		if ( arr [ l ] + arr [ r ] > 0 ) :
			count += ( r - l ) ;
			r -= 1 ;
		else :
			l += 1 ;
	return count ;
if __name__ == " _ _ main _ _ " :
	arr = [ - 7 , - 1 , 3 , 2 ] ;
	n = len ( arr ) ;
	print ( CountPairs ( arr , n ) ) ;