diff --git a/Smart_Calculator/calculator.py b/Smart_Calculator/calculator.py index 2c46b4eb..32a23d13 100644 --- a/Smart_Calculator/calculator.py +++ b/Smart_Calculator/calculator.py @@ -1,4 +1,6 @@ from tkinter import * +PI = 3.14159 + def add(a,b): return a + b @@ -58,6 +60,21 @@ def calculate(): list.delete(0,END) list.insert(END,'something went wrong please enter again') + +def fact(n): + if n == 1 or n == 0: + return 1 + return n * fact(n - 1) + + +def circle_area(radius): + return PI * (radius ** 2) + + +def circle_perimeter(radius): + return PI * radius * 2 + + operations = {'ADD':add,'ADDITION':add, 'SUM':add, 'PLUS':add, 'SUB':sub, 'DIFFERENCE':sub, 'MINUS': sub, 'SUBTRACT':sub, 'DIFF':sub, 'LCM':lcm, 'HCF':hcf, 'PRODUCT':mul, 'MULTIPLICATION':mul, diff --git a/Smart_Calculator/calculator_test.py b/Smart_Calculator/calculator_test.py index e44e858c..78b53ccf 100644 --- a/Smart_Calculator/calculator_test.py +++ b/Smart_Calculator/calculator_test.py @@ -30,4 +30,4 @@ def test_hcf_function(self): self.assertEqual(hcf(54, 24), 6) if __name__ == '__main__': - unittest.main(verbosity=2) \ No newline at end of file + unittest.main(verbosity=2) diff --git a/Triangle Calculator/TriangleCalculator.py b/Triangle Calculator/TriangleCalculator.py index def30492..fcaf8590 100644 --- a/Triangle Calculator/TriangleCalculator.py +++ b/Triangle Calculator/TriangleCalculator.py @@ -8,4 +8,9 @@ #Calculate the area area=(sp*(sp-s1)*(sp-s2)*(sp-s3))**0.5 -print('The area of the triangle is %0.4f'%area) \ No newline at end of file +#Calculate the perimeter +perimeter = s1 + s2 + s3 + +print('The area of the triangle is %0.4f'%area) + +print('The perimeter of the triangle is %0.4f'%perimeter)