-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.py
57 lines (39 loc) · 1.66 KB
/
Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Created by Ahmer Aamir
# Created on 8 oct 2022
import math as mt
class BasicCalc:
def __init__(self, num1, num2):
self.first = num1
self.second = num2
def addition(self):
return self.first + self.second
def subtraction(self):
return self.first - self.second
def multiplication(self):
return self.first * self.second
def division(self):
return self.first / self.second
class SecondaryCalc(BasicCalc):
def __init__(self, first, second):
self.first = first
self.second = second
def factorial(self):
return mt.factorial(self.first), mt.factorial(self.second)
def power(self):
return mt.pow(self.first, self.second)
def log(self):
return mt.log10(self.first), mt.log10(self.second)
def ln(self):
return mt.log(self.first), mt.log(self.second)
num1 = int(input("Please Enter First Number: "))
num2 = int(input("Please Enter Second Number: "))
BCalc = BasicCalc(num1, num2)
SCalc = SecondaryCalc(num1, num2)
print("\n> Sum of ", num1, " and ", num2, " is: ", BCalc.addition())
print("> Subtraction of ", num1, " and ", num2, " is: ", BCalc.subtraction())
print("> Multiplication of ", num1, " and ", num2, " is: ", BCalc.multiplication())
print("> Dvision of ", num1, " and ", num2, " is: ", BCalc.division())
print("\n> Factorial of (", num1, ", ", num2, ") is: ", SCalc.factorial())
print("> (", num1, " pow ", num2, ") is: ", SCalc.power())
print("> Standard Log of (", num1, ", ", num2, ") is: ", SCalc.log())
print("> Natural Log of (", num1, ", ", num2, ") is: ", SCalc.ln())