Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function named create _ mat that creates a square matrix of an arbitrary size having the structure given in the example below. This
Write a function named createmat that creates a square matrix of an arbitrary size having the structure given in the example below. This function should take the size of a square matrix as an integer n and outputs the special matrix S as shown in the example below. You MUST use numpy arrays to create this matrix.
The code has already been provided to define a function named createmat that accepts the input variable n and returns the output variable S
Examples:
Note that n is defined as input to the function. Do not overwrite values in this variable in your code. Be sure to assign a value to the function output variable S
HARDCODING IS NOT ALLOWED!!! IT MEANS, YOU CANNOT DIRECTLY PRINT THE RESULT WITHOUT PERFORMING ANY OPERATIONS. OTHERWISE, YOU CANNOT PASS THE HIDDEN TESTS!!!
DO NOT CHANGE ANYTHING IN THE TEMPLATE ASIDE FROM ADDING YOUR OWN CODE IN THE SPECIFIED AREA. OTHERWISE THE TESTS MIGHT NOT WORK AND YOU WILL NOT BE ABLE TO PASS THEM!!!!!
DO NOT USE ANY BUILTIN FUNCTION ie count index reverse sort sorted etc. in PYTHON.
For example:
Test Result
printnpasarraycreatematdtypeint
printnpasarraycreatematdtypeint
Answer:penalty regime:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started