Given polynomial write a prigram that prints polynomial in Cix^Pi + Ci-1x^Pi-1....+C1x+C0 format.
sample input:
4
0 5
1 0
2 10
3 6
sample output:
6x^3 + 10x^2 + 5
def Polynomial(p, n):
for i in range(n):
print(p[i], end="")
if (i != 0):
print(" x^", i, end="")
if (i != n - 1):
print(" + ", end="")
if __name__ == '__main__':
print(Polynomial([3, 2, 6, 11], 8))
Comments
Leave a comment