Problem Statement:
We need to take an integer(n) as input, then next to n lines, there will be two separated integers representing Pi and Ci of a polynomial. We need to represent those Pi and Ci in polynomial form.
For example,
Input
Enter number of terms in polynomial: 5
1 2
2 3
3 4
0 9
7 6
Output
6x^7 + 4x^3 + 3x^2 + 2x^1 + 9x^0
Code for Polynomial in Python:
n = int(input('Enter number of terms in polynomial: ')) Pi = [] Ci = [] for i in range(n): pi_ci = input().split() Pi.append(pi_ci[0]) Ci.append(pi_ci[1]) poly = [] for i in range(n): poly.append(Ci[i] + 'x^'+Pi[i]) Pi.sort(reverse=True) newPoly = [] for i in range(n): for j in range(n): if Pi[i]==poly[j][3]: newPoly.append(poly[j]) print(' + '.join(newPoly))
Output:

Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python