human
Interchange elements of first and last rows in matrix | Python code to swap the element of first and last row and display the result.
swapping of element between first and last rows.
input in the array.
printing the interchanged matrix"
Solution in Python:
assistant
#Here is code to interchange elements of first and last rows in matrix and the other steps required.
 def interchangeFirstLast ( mat , n , m ) :
	rows = n
	for i in range ( n ) :
		t = mat [ 0 ] [ i ]
		mat [ 0 ] [ i ] = mat [ rows - 1 ] [ i ]
		mat [ rows - 1 ] [ i ] = t
mat = [ [ 8 , 9 , 7 , 6 ] , [ 4 , 7 , 6 , 5 ] , [ 3 , 2 , 1 , 8 ] , [ 9 , 9 , 7 , 7 ] ]
n = 4
m = 4
interchangeFirstLast ( mat , n , m )
for i in range ( n ) :
	for j in range ( m ) :
		print ( mat [ i ] [ j ] , end = " ▁ " )
	print ( " " )