
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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 Articles
- 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 specific axis in Python
- Differentiate a polynomial with multidimensional coefficients over axis 1 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
- Remove small trailing coefficients from Laguerre polynomial in Python
- Remove small trailing coefficients from Chebyshev polynomial in Python
- Remove small trailing coefficients from Hermite polynomial in Python

Advertisements