def main(): parser = argparse.ArgumentParser() parser.add_argument('--function', type=str, required=True, nargs='+') args = parser.parse_args() arguments = args.function method_name = arguments[0] angle = arguments[1] calc = ScientificCalc() if method_name == 'calculate_sin': res = calc.calculate_sin(angle) print(res) else: print("method not found")
def main(): input1 = sys.argv[1] input2 = sys.argv[2] addcalc = ScientificCalc() result1 = addcalc.addition(input1, input2) print(result1) result2 = addcalc.subtraction(input1, input2) print(result2) result3 = addcalc.multiply(input1, input2) print(result3) result4 = addcalc.divide(input1, input2) print(result4)
def test_square_root_positive(self): """test case for positive value""" test = ScientificCalc() self.assertEqual(test.square_root(4), 2.0)
def test_square_root_string(self): """test case if we give string""" test = ScientificCalc() self.assertEqual(test.square_root("a"), "expecting integer value")
def test_square_root_negative(self): """test case for negative value""" test = ScientificCalc() self.assertEqual(test.square_root(-8), complex(1.7319121124709868e-16 + 2.8284271247461903j))
def test_addition(self): """calculating the positive addition value""" calc = ScientificCalc() self.assertEqual(calc.addition(2, 2), 4)
def test_error(self): """non integer inputs""" calc = ScientificCalc() self.assertEqual(calc.addition(2, 'a'), "Enter only numbers")
def test_zeroerror(self): """non integer inputs""" calc = ScientificCalc() self.assertEqual(calc.divide(2, 0), "Enter a number greater than zero")
def test_divide(self): """calculating the division""" calc = ScientificCalc() self.assertEqual(calc.divide(4, 2), 2)
def test_multipy(self): """calculating the multiplication """ calc = ScientificCalc() self.assertEqual(calc.multiply(5, 3), 15)
def test_subtraction(self): """calculating the subtraction value""" calc = ScientificCalc() self.assertEqual(calc.subtraction(5, 3), 2)
def test_case2(self): calc = ScientificCalc() self.assertEqual(calc.calculate_sin('uyh'), 'It is not number')
def test_case1(self): calc = ScientificCalc() self.assertEqual(calc.calculate_sin('30'), -0.9880316240928618)