From 252014fe537052437999b2f691d67a7e18ccd9c5 Mon Sep 17 00:00:00 2001 From: Maleda Tessema Date: Sat, 7 Mar 2020 19:06:41 -0500 Subject: [PATCH 1/2] Display 90% --- display.py | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 display.py diff --git a/display.py b/display.py new file mode 100644 index 0000000..f82c2c3 --- /dev/null +++ b/display.py @@ -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 From 477f10b91388999647901501a31940db398dfa35 Mon Sep 17 00:00:00 2001 From: Maleda Tessema Date: Sat, 7 Mar 2020 19:50:41 -0500 Subject: [PATCH 2/2] fixed merege conflict --- calculator.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/calculator.py b/calculator.py index 8159a46..f6ca936 100644 --- a/calculator.py +++ b/calculator.py @@ -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)) @@ -57,12 +57,12 @@ 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): @@ -70,7 +70,7 @@ def ln(self, 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))