def test_term_spitter_raises_exception_with_coefficient_and_power_only( self): test_term = '2^2' exc = None try: term_splitter(test_term) except Exception as err: exc = err self.assertIsNotNone(exc) self.assertEqual( str(exc), "Error: Estimates can be made. Recalculate and call the function again." )
def main(): validate_call(sys.argv) my_list = parser(sys.argv[1]) term_list = [] for elem in my_list: term = term_splitter(elem) term_list.append(Term(term)) function = Polynomial(term_list) print(f"The derivative of f(x) = {function}") print(f"f'(x) = {function.derivative()}")
def test_term_spitter_passes_with_variable_and_power_only(self): test_term = 'x^2' self.assertEqual(term_splitter(test_term), [None, True, 2])
def test_term_spitter_passes_with_variable_coefficient_and_power(self): test_term = '24x^2' self.assertEqual(term_splitter(test_term), [24, True, 2])
def test_term_spitter_passes_with_variable_and_coefficient_only(self): test_term = '24x' self.assertEqual(term_splitter(test_term), [24, True, None])
def test_term_spitter_passes_with_coefficient_only(self): test_term = '24' self.assertEqual(term_splitter(test_term), [24, False, None])