Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code which reads a text file containing polynomials f1, f2, ..., fk and takes an input value x0 from a user and calculates

Write a code which reads a text file containing polynomials f1, f2, ..., fk and takes an input value x0 from a user and calculates the values f1(x0), f2(x0), ..., fk(x0) and writes these values to the same text file according to the format shown in the following: x_2=2 should be inside of the code input= input1.txt f1(x): +3x^2 + 2x^1 -5x^0 f2(x): -5x^3 + 1x^1 +7x^0 f3(x): +4x^4 - 2x^0 output: f1(x): +3x^2 + 2x^1 -5x^0 f2(x): -5x^3 + 1x^1 +7x^0 f3(x): +4x^4 - 2x^0 f1(2): 11 f2(2): -31 f3(2): 62 We are not allow to use import and .findall image text in transcribed my code : image text in transcribed

4. Write a code which reads a text file containing polynomials f1,f2,,fk and takes an input value x0 from a user and calculates the values f1(x0),f2(x0),,fk(x0) and writes these values to the same text file according to the format shown in the following: Sample input and output Note 1: There is at least one space between the terms of each polynomial fi(x) in the input text file. Use these spaces for splitting purposes. Note 2: You are allowed to use Python's pow () function when calculating fi(x0). ValueError Traceback (most recent call last) Cell In[4], line 27 25 if " f " in polynomial: polynomial = polynomial [3: ] 27 result = evaluate_polynomial(polynomial, x ) 29 f.write (f f({x})={ result } ) Cell In[4], line 12, in evaluate_polynomial(polynomial, x) 10 exponent = " " 11 if coefficient[-1].isnumeric(): 12 coefficients.append((float(coefficient), int(exponent))) 13 result = 14 for coefficient, exponent in coefficients: ValueError: could not convert string to float: ' x):\xa+4

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

Step: 3

blur-text-image

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago