Question: SAMPLE SESSION: Write a program p3.py that reads in a string fun_str from the terminal a mathematical function definition that uses symbol x as a

SAMPLE SESSION:

Write a program p3.py that reads in a string fun_str from the terminal a mathematical function definition that uses symbol x as a parameter, a domain (float [Xmin,Xmax] interval), and the number of samples ns (an integer), and then: 1. computes a list xs with fs sample points evenly dividing thexmin Xmx] interval 2. computes a list ys with the results of applying the function definition in string fun_str, with x traversing the elements from list xs displays a nice table with the xs and ys values, as shown in the figure below, using the format string method displays the figure with the chart of the function defined in fun_str using domain samples in list xs, the corresponding range values in list ys, and the functions from the pylab module. 3. 4. IMPORTANT: This problem is very similar to a part of problem 2 from Homework 1. This time, however, instead of using a hardcoded function y(x)=a"X**2+b*x+c, we will use a function whose expression is given by the interactive user. The user can rely on the functions in the math package. For instance, the user can enter the following expression for the fun_str variable 2*math.sin(2*math.pi *x) The program reads string fun str: fun str = input ("Enter function with variable x: ) The program calls the Python evalO function to evaluate the function expression for the current value of x: for x in xs: y = eval(fun_str) ys.append (y)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
