Question: func1(n): Implement a function called funct such that: func1 has 1 input: Integer n (you can assume n 23, no need for error checking) func1

 func1(n): Implement a function called funct such that: func1 has 1
input: Integer n (you can assume n 23, no need for error
checking) func1 returns an n by n Numpy matrix that has an

func1(n): Implement a function called funct such that: func1 has 1 input: Integer n (you can assume n 23, no need for error checking) func1 returns an n by n Numpy matrix that has an outer frame of 1s and all inner values are Os Return value when n=4: [[1.1.1.1.) [1.0.0.1.) [1.0.0.1.) (1.1.1.1.) Return value when n=5: [1.1.1.1.1.1 [1.0.0.0.1.] [1.0.0.0.1.) [1.0.0.0.1.) [1.1.1.1.1.]] func2(n): We would like to approximate the function y = x' by evaluating it at multiple x values and plotting the corresponding values of the function. Implement a function called func2 such that: func2 has 1 input integer func2 creates n equally spaced x values between (-40, +40) and computes y = x at each of these x values. x values should start with -40 and end with +40. func2 creates a line graph of the x values and y values found in the previous step Title of plot should be: y = x 2 Approximation X axis label should be: "Values of Y axis label should be: "Values of y You do not need to modify any other details of the plot 0 o Here are the plots generated by func2 when n=7 and n=20 respectively. As n becomes larger, you should be able to visually verify that the line graph is a better (smoother) approximation of the function y = x y = x^2 Approximation y = x^2 Approximation 1600 1600 2400 1400 1200 1200 1000 3000 800 Values of y Valueet 900 600 FOO 400 400 200 200 o 30 -10 -30 40 30 20 -20 10 Cio 0 Values of import numpy snp import matplot lib.pyplot s plt def Funciin): return -1 def func2(n): pass def main(): print(func1(5)) #print(func1(8)) #func2(20)

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 Databases Questions!