solution

Write a python code that can do the following:

Read a text file (the filename is inputted by the user) ex

4

5.5 3.2 1 0 3.3

which contains 2 lines where the first line is an integer n, and the second line contains n+1 real numbers (e.g., a[0], a[1],…, a[n]) as coefficients. In particular, a[i] is the coefficient associated with x^i. For example, n=4, a=[5.5 3.2 1 0 3.3 ] defines f(x)= 5.5 – 3.2 x + 1 x^2 + 3.3 x^4

  1. Print out the f(x) like the following
    f(x)= 5.5 – 3.2 x + 1 x^2 + 3.3 x^4
    the format should be :
    1. do not print out 0 terms
    2. leave a space before/after an operator (+ or -)
    3. leave a space between the x term and its associated coefficient
    4. the power of x should be printed out like x^2 (i.e., no space inside the term)
  2. Then, keep asking the user to input the value of x (can be a real number), say, b, then print out the value of f(b).
    Repeat this step, unless the user input 0 (i.e., if b=0, then this program print out a[0] and STOP)
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"