Question: Write a function called matrix ( n ) that takes an integer greater than 2 as an argument. If n is odd, the function should

Write a function called matrix(n) that takes an integer greater than 2 as an argument. If n is odd, the function should return an n x n matrix with 1s everywhere except for the middle of the matrix, which should contain a 0. If n is even, the function should should an n x n matrix with 0s everywhere except for the 4 cells in the middle, which should contain 1s

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!