From f2eca4e6f119eb99e840023425f19342dfb58973 Mon Sep 17 00:00:00 2001 From: Nash Date: Mon, 20 Jan 2020 13:00:35 -0500 Subject: [PATCH] initial commit --- zommath2.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 zommath2.py diff --git a/zommath2.py b/zommath2.py new file mode 100644 index 0000000..44990c8 --- /dev/null +++ b/zommath2.py @@ -0,0 +1,58 @@ +from math import sqrt + + +def bogocalc(buy, get, discount, price): + total = buy + get + + buy_cost = buy * price + get_cost = get * price + unitprice = buy_cost + get_cost * (1 - discount / 100) + return unitprice / total + + +class Quadratic: + def __init__(self, a=None, b=None, c=None): + self._a = a + self._b = b + self._c = c + + def set_nums(self, a, b, c): + self._a = a + self._b = b + self._c = c + + def deter(self): + return self._b**2 - 4 * self._a * self._c + + def plusans(self): + top_plus = self._b - sqrt(self.deter()) + plus_ans = top_plus / (2 * self._a) + + return plus_ans + + def minusans(self): + top_minus = self._b + sqrt(self.deter()) + minus_ans = top_minus / (2 * self._a) + + return minus_ans + + def __str__(self): + return f"{self._a}x^2 + {self._b}x + {self._c}" + + +if __name__ == "__main__": + q = Quadratic(1, 2, -3) + print(f"-2 ± √({q.deter()})") + print(2*1) + for a in range(1, 10): + q.set_nums(a, 2, -3) + print(f"Solving: {q}") + print(f"Plus ans: {q.plusans()}") + print(f"Minus ans: {q.minusans()}") + print(f"Determinant: {q.deter()}") + + + + +#3 for 3 sale +#buy x get y z% off`