Answered step by step
Verified Expert Solution
Link Copied!

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 create_mat 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 create_mat 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 BUILT-IN FUNCTION (i.e., count(), index(), reverse(), sort(), sorted(), etc.) in PYTHON.
For example:
Test Result
print(np.asarray(create_mat(5),dtype=int))
[[11010]
[311303]
[5131950]
[71521257]
[917232729]]
print(np.asarray(create_mat(10),dtype=int))
[[1101010101]
[32130303030]
[523395050505]
[7254155707070]
[92743576990909]
[112945597181110110]
[1331476173839113013]
[1533496375859399150]
[1735516577879510110517]
[19375367798997103107109]]
Answer:(penalty regime: 0%)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago