

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Compute a Polynomial Equation given that the Coefficients of the Polynomial are stored in a List
When it is required to compute a polynomial equation when the coefficients of the polynomial are stored in a list, a simple ‘for’ loop can be used.
Below is the demonstration of the same −
Example
my_polynomial = [2, 5, 3, 0] num = 2 poly_len = len(my_polynomial) my_result = 0 for i in range(poly_len): my_sum = my_polynomial[i] for j in range(poly_len - i - 1): my_sum = my_sum * num my_result = my_result + my_sum print("The polynomial equation for the given list of co-efficients is :") print(my_result)
Output
The polynomial equation for the given list of co-efficients is : 42
Explanation
A list is defined.
A number is specified, and the length of the list is assigned to a variable.
A result variable is declared as 0.
The length of the list is iterated over, and the sum is added to the number.
This is given as the output.
This is displayed on the console.
- Related Questions & Answers
- Python program to compute a Polynomial Equation
- Compute the roots of a polynomial in Python
- Compute the roots of a polynomial with given complex roots in Python
- Evaluate a polynomial when coefficients are multi-dimensional in Python
- Differentiate a polynomial with multidimensional coefficients in Python
- C program to compute the polynomial regression algorithm
- Remove small trailing coefficients from a polynomial in Python
- Return the companion matrix of a 1-D array of polynomial coefficients in Python
- Differentiate a polynomial with multidimensional coefficients over axis 1 in Python
- Differentiate a polynomial with multidimensional coefficients over specific axis in Python
- Return the scaled companion matrix of a 1-D array of Laguerre polynomial coefficients in Python
- Return the scaled companion matrix of a 1-D array of Legendre polynomial coefficients in Python
- Minimize the sum of roots of a given polynomial in C++
- Remove small trailing coefficients from Chebyshev polynomial in Python
- Remove small trailing coefficients from Hermite polynomial in Python
Advertisements