Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def cosecrad(self, num):
print('Inverse Sine(%f) = %f' % (num, answer))
def secrad(self, num):
answer = 1/(math.cos(num))
print('Inverse Cosine(%f) = %f' % (numb, answer))
print('Inverse Cosine(%f) = %f' % (num, answer))
def cotrad(self, num):
answer = 1/(math.tan(num))
print('Inverse Tangent(%f) = %f' % (numb, answer))
print('Inverse Tangent(%f) = %f' % (num, answer))
def sindeg(self, num):
answer = math.sin(math.radians(num))
print('Sin(%f) in Degrees = %f' % (num, answer))
Expand All @@ -57,20 +57,20 @@ def cosecdeg(self, num):
answer = 1/(math.sin(math.radians(num)))
print('Inverse Sine(%f) in Degrees = %f' % (num, answer))
def secdeg(self, num):
answer = 1/(math.cos(math.radians(num))
print('Inverse Cosine(%f) in degrees = %f' % (numb, answer))
answer = 1/(math.cos(math.radians(num)))
print('Inverse Cosine(%f) in degrees = %f' % (num, answer))
def cotdeg(self, num):
answer = 1/(math.tan(math.radians(num)))
print('Inverse Tangent(%f) in degrees = %f' % (numb, answer))
def factorial(self, num)
print('Inverse Tangent(%f) in degrees = %f' % (num, answer))
def factorial(self, num):
answer = math.factorial(num)
print('Factorial (%f) = %f' % (num, answer))
def ln(self, num):
answer = math.log(num)
print('Log (%f) = %f' % (num, answer))
def logten(self, num):
answer = math.log10(num)
print(Log10(%f) = %f' % (num, answer))
print('Log10(%f) = %f' % (num, answer))
def logbasex(self, num, x):
answer = math.log(num, x)
print('Log base (%f)(%f) = %f' % (x, num, answer))
Expand Down
99 changes: 99 additions & 0 deletions display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# import the class
from calc import calc

cal = calc()
print("Scientific calculator")
print("List of choice:")
print('-' * 20)
print("1 : Addition \t\t 12 : Sine in degrees")
print("2 : Subtraction \t 13 : Cosine in degrees")
print("3 : Multiplication \t 14 : Tan in degrees")
print("4 : Division \t\t 15 : Cosecant in degrees")
print("5 : Sine in radians \t 16: Secant in degrees")
print("6 : Cosine in radians \t 17 : cot in degrees")
print("7 : Tan in radians \t 18 : Natural log")
print("8 : Cosecant in radians 19 : Base 10 log")
print("9 : Secant in radians \t 20 : Log base'x'")
print("10 : Cot in radians \t 21 : Square root")
print("11 : pi \t\t 22 : Power of")
print('-' * 20)
choice = ""
while True:
try:
choice = int(input("Enter the number of choice: "))
except:
print("Enter a valid number: (")
if choice == 1:
n1 = float(input("Enter the first number to add : "))
n2 = float(input("Enter the second number to add : "))
cal.add(n1, n2)
elif choice == 2:
n1 = float(input("Enter the first number to subtract : "))
n2 = float(input("Enter the second number to subtract : "))
cal.sub(n1, n2)
elif choice == 3:
n1 = float(input("Enter the first number to multiply : "))
n2 = float(input("Enter the second number to multiply : "))
cal.mul(n1, n2)
elif choice == 4:
n1 = float(input("Enter the first number for division : "))
n2 = float(input("Enter the second number for division : "))
cal.div(n1, n2)
elif choice == 5:
n = float(input("Enter a number to find its Sine in radians : "))
cal.sinrad(n)
elif choice == 6:
n = float(input("Enter a number to find its Cos in radians : "))
cal.cosrad(n)
elif choice == 7:
n = float(input("Enter a number to find its Tan in radians : "))
cal.tanrad(n)
elif choice == 8:
n = float(input("Enter a number to find its Cosecant in radians : "))
cal.cosecrad(n)
elif choice == 9:
n = float(input("Enter a number to find its Secant in radians : "))
cal.secrad(n)
elif choice == 10:
n = float(input("Enter a number to find its Cot in radians : "))
cal.cotrad(n)
elif choice == 11:
cal.pie()
elif choice == 12:
n = float(input("Enter a number to find its Sine in degrees : "))
cal.sindeg(n)
elif choice == 13:
n = float(input("Enter a number to find its Cosine in degrees : "))
cal.cosdeg(n)
elif choice == 14:
n = float(input("Enter a number to find its Tan in degrees : "))
cal.tandeg(n)
elif choice == 15:
n = float(input("Enter a number to find its Cosecant in degrees : "))
cal.cosecdeg(n)
elif choice == 16:
n = float(input("Enter a number to find its Secant in degrees : "))
cal.secdeg(n)
elif choice == 17:
n = float(input("Enter a number to find its Cot in degrees : "))
cal.cotdeg(n)
elif choice == 18:
n = float(input("Enter a number to find its Natural in log : "))
cal.ln(n)
elif choice == 19:
n = float(input("Enter a number to find its Base 10 log : "))
cal.logten(n)
elif choice == 20:
n1 = float(input("Enter base value : "))
n2 = float(input("Enter a number to find its log to the given log value : "))
cal.logbasex(n1, n2) # steps are made like functions
elif choice == 21:
n = float(input("Enter a number to get it's Square root : "))
cal.squareroot(n)
elif choice == 22:
n1 = float(input("Enter a number : "))
n2 = float(input("Enter its power"))
cal.powerof(n1, n2)
else:
print("ERROR : Please enter a valid number ")
# Let's merege and test