human
Give me a code to sum of matrix in which each element is absolute difference of its row and column numbers and the other steps required given the following:
Sum of matrix in which each element is absolute difference of its row and column numbers | Return the sum of matrix in which each element is absolute difference of its corresponding row and column number row.
Generate matrix.
Compute sum.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to sum of matrix in which each element is absolute difference of its row and column numbers and the other steps required.
 def findSum ( n ) :
	arr = [ [ 0 for x in range ( n ) ] for y in range ( n ) ]
	for i in range ( n ) :
		for j in range ( n ) :
			arr [ i ] [ j ] = abs ( i - j )
	sum = 0
	for i in range ( n ) :
		for j in range ( n ) :
			sum += arr [ i ] [ j ]
	return sum
if __name__ == " _ _ main _ _ " :
	n = 3
	print ( findSum ( n ) )