Question

The code should be written with python.

Question 1: Computing Polynomials [35 marks A polynomial is a mathematical expression that can be built using constants and v

Your Task Your task is to write function calc_poly (const_seq, var_poly) to compute the value of a polynomial function. The d

Your function must return the computed value of the polynomial function. Example: Suppose we want to evaluate the above illus

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the required python3 script that can handle both list and tuples (respective examples are given for both):

Note: Please mind the text indentation in function and for loop blocks!! An image of the same is being provided for help!

#=====================================================

def calc_poly(const_seq,var_poly):

   const_seq = list(const_seq); # To list conversion

   poly_val = 0; # Initializing summation variable

   for i in range(len(const_seq)):

      poly_val=poly_val + const_seq[i]*(var_poly**i); # Performing polynomial sum

   poly_val = round(poly_val,2); # Rounding upto 2 fractional digits

   return poly_val;


#========= Driver Program =========

const_seq = [3,-9,1,2]; # List version

var_poly = 2.3478;

print('Polynomial Value by list =',calc_poly(const_seq,var_poly));

const_seq = (3,-9,1,2); # Tuple version

var_poly = 2.3478;

print('Polynomial Value by tuple =',calc_poly(const_seq,var_poly));

#==================================================

Code image with proper indentation:

def calc poly(const_seq, var_poly): const_seq = list(const seq); # To list conversion poly_val = 0; # Initializing summation

Output:

Polynomial Value by list = 13.26 Polynomial Value by tuple = 13.26

Hope this helps!

*********** PLEASE THUMBS UP!!!!! *************

Add a comment
Answer #2
(a) What is the mathematical expression of the polynomial model if there is a single input variable X and one output variable Y?
Add a comment
Know the answer?
Add Answer to:
The code should be written with python. Question 1: Computing Polynomials [35 marks A polynomial is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT