from itertools import zip_longest
class Polinomio:
"""
Polinomio en una variable
var : la variable (x, y, z, ...)
coeficientes: lista de coeficientes para [x^0, x^1, x^2, x^3, ...]
"""
def __init__(self, var: str, coeficientes: list):
self.var = var
self.coeficientes = coeficientes
def __add__(self, other):
if isinstance(other, Polinomio) and self.var == other.var:
resultado = Polinomio(self.var, [x+y for x,y in zip_longest(self.coeficientes, other.coeficientes,fillvalue=0)])