Userdefined inputoutput and logical statements Consider the

User-defined input-output and logical statements. Consider the following function: y = e^3x^2+ 4/5x + 36 x + 1 It is desired that this function be evaluated for a variety of user-defined values of x. Create a script file/segment of code that will allow the user to neatly and professionally input a scalar OR vector value of x. Evaluate the function at 3 user-selected points as well as a single user-defined vector input. Display the result using dispO- Be sure to include some output text in addition to displaying the function evaluation result.

Solution

# python

import math
x = input(\"Enter a scalar or vector(space separated values):\ \")
def display(res):
print res
if(isinstance(x,(int,long,float))):
display(math.exp(x**2 + (4/5)*x) + 36*x + 1)
else:
   vector = [float(y) for y in x.split()]
   result = []
   for y in vector:
       result.append(math.exp(y**2 + (4/5)*y) + 36*y + 1)
   display(result)

input output
0 2.0
1.25 50.770733182
-13 2.48752492832e+73
1.5 2 -4 [64.4877358364, 127.598150033, 8885967.52051]
 User-defined input-output and logical statements. Consider the following function: y = e^3x^2+ 4/5x + 36 x + 1 It is desired that this function be evaluated fo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site