From 8043d7b2f92eb0b79f6c66c047cde2cb5d7a5db0 Mon Sep 17 00:00:00 2001 From: "quentin.fasler" <quentin.fasler@etu.hesge.ch> Date: Tue, 7 Dec 2021 10:58:31 +0100 Subject: [PATCH] add pass_x_throughout --- polynomial.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/polynomial.py b/polynomial.py index ef82cc0..e385491 100644 --- a/polynomial.py +++ b/polynomial.py @@ -16,8 +16,12 @@ class Polynomial: self.value = value def pass_x_throughout(self, x): - pass - + a = list(self.value) + sum = (a[len(a)-1]*x)+a[len(a)-2] + for i in reversed(range(len(a)-2)): + sum = sum*x+a[i] + return sum + def __add__(self, other): a = list(self.value) b = list(other.value) -- GitLab