From 554307f8dc9b113382c3fb17545a0b14028fb04b Mon Sep 17 00:00:00 2001 From: Christian Chavez Date: Sat, 7 Mar 2020 18:58:09 -0500 Subject: [PATCH 01/13] Basic Features Chris Chavez --- calculator.py | 90 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/calculator.py b/calculator.py index 3c85ead..8159a46 100644 --- a/calculator.py +++ b/calculator.py @@ -1,12 +1,80 @@ -class Calculator: +import math - def __init__(self): - pass - - def add(self, x, y): - return x + y - - def sub(self, x, y): - return 0 - -# add lots more methods to this calculator class. +class Calculator(object): + def add(self, num1, num2): + answer = num1 + num2 + print('Sum = ', answer) + def sub(self, num1, num2): + answer = num1 - num2 + print('Difference = ', answer) + def mul(self, num1, num2): + answer = num1 * num2 + print('Multiplication = ', answer) + def div(self, num1, num2): + answer = num1 / num2 + print('Division = ', answer) + def powerof(self, num, raiseby): + answer = math.pow(num, raiseby) + print('%f ^ %f = %f' % (num, raiseby, answer)) + def square(self, num): + answer = math.pow(num, 2) + def squareroot(self, num): + answer = math.sqrt(num) + print("Square root (%f) = %f" % (num, answer)) + def inverse(self, num): + answer = 1/(num) + print('Inverse (%f) = %f' % (num, answer)) + def switchsign(self, num): + print(1-(num<=0)) + def sinrad(self, num): + answer = math.sin(num) + print('Sine (%f) = %f' %(num, answer)) + def cosrad(self, num): + answer = math.cos(num) + print('Cosine (%f) = %f' %(num, answer)) + def tanrad(self, num): + answer = math.tan(num) + print('Tangent (%f) = %f' %(num, answer)) + def cosecrad(self, num): + answer = 1/(math.sin(num)) + print('Inverse Sine(%f) = %f' % (num, answer)) + def secrad(self, num): + answer = 1/(math.cos(num)) + print('Inverse Cosine(%f) = %f' % (numb, answer)) + def cotrad(self, num): + answer = 1/(math.tan(num)) + print('Inverse Tangent(%f) = %f' % (numb, answer)) + def sindeg(self, num): + answer = math.sin(math.radians(num)) + print('Sin(%f) in Degrees = %f' % (num, answer)) + def cosdeg(self, num): + answer = math.cos(math.radians(num)) + print('Cos(%f) in Degrees = %f' % (num, answer)) + def tandeg(self, num): + answer = math.tan(math.radians(num)) + print('Tan(%f) in Degrees = %f' % (num, answer)) + 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)) + def cotdeg(self, num): + answer = 1/(math.tan(math.radians(num))) + print('Inverse Tangent(%f) in degrees = %f' % (numb, 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)) + def logbasex(self, num, x): + answer = math.log(num, x) + print('Log base (%f)(%f) = %f' % (x, num, answer)) + def pie(self): + print('pi = ', math.pi) + def e_constant(self): + print('e = ', math.e) From 252014fe537052437999b2f691d67a7e18ccd9c5 Mon Sep 17 00:00:00 2001 From: Maleda Tessema Date: Sat, 7 Mar 2020 19:06:41 -0500 Subject: [PATCH 02/13] 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 3b93bd35cb1965be3401e3467f36baf4dbc45437 Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sat, 7 Mar 2020 19:08:48 -0500 Subject: [PATCH 03/13] branch_Creation --- calctests.py | 35 +++++++++++++++++++++++++++++++++++ calculator.py | 5 +++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/calctests.py b/calctests.py index 1964570..55808f3 100644 --- a/calctests.py +++ b/calctests.py @@ -20,6 +20,41 @@ def test_sub(self): c = Calculator() self.assertEqual(c.sub(9, 3), 6) + def test_sub2(self): + c = Calculator() + self.assertEqual(c.sub(-4, 3), -7) + + def test_sub3(self): + c = Calculator() + self.assertEqual(c.sub(123.2, .2), 123) + + def test_mul1(self): + c = Calculator() + self.assertEqual(c.mul(4, .5), 2) + + def test_mul2(self): + c = Calculator() + self.assertEqual(c.mul(5, 5), 25) + + def test_mul3(self): + c = Calculator() + self.assertEqual(c.mul(10, -1), -10) + + def test_div(self): + c = Calculator() + self.assertEqual(c.div( 25,5 ), 5) + + def test_div(self): + c = Calculator() + self.assertEqual(c.div( 10,-2 ),-5) + + def test_div(self): + c = Calculator() + self.assertEqual(c.div( 10,-2 ),-5) + + def test_div(self): + c = Calculator() + self.assertEqual(c.div( 10,-2 ),-5) if __name__ == '__main__': unittest.main() diff --git a/calculator.py b/calculator.py index 3c85ead..1d78738 100644 --- a/calculator.py +++ b/calculator.py @@ -1,7 +1,8 @@ class Calculator: - def __init__(self): - pass + def __init__(self,num1,num2): + self.num1 = num1 + self.num2 = num2 def add(self, x, y): return x + y From 477f10b91388999647901501a31940db398dfa35 Mon Sep 17 00:00:00 2001 From: Maleda Tessema Date: Sat, 7 Mar 2020 19:50:41 -0500 Subject: [PATCH 04/13] 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)) From 26913962b14806c3b7fec888427c776ef4f88a03 Mon Sep 17 00:00:00 2001 From: Christian Chavez Date: Sat, 7 Mar 2020 19:56:47 -0500 Subject: [PATCH 05/13] With corrections --- 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)) From 5e0d23a4be1f952d746097f6db3c0951f4e91a4a Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 00:49:08 -0500 Subject: [PATCH 06/13] repeated asks solved --- main-app.py | 154 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 130 insertions(+), 24 deletions(-) diff --git a/main-app.py b/main-app.py index 3613251..263839f 100644 --- a/main-app.py +++ b/main-app.py @@ -5,85 +5,169 @@ class Calculator(object): def add(self, num1, num2): answer = num1 + num2 print('Sum = ', answer) + return answer def sub(self, num1, num2): answer = num1 - num2 print('Difference = ', answer) + return answer def mul(self, num1, num2): answer = num1 * num2 print('Multiplication = ', answer) + return answer def div(self, num1, num2): if num2 != 0: print('Division = ', (num1 / num2)) + return (num1/num2) else: print("Err") def powerof(self, num, raiseby): answer = math.pow(num, raiseby) print('%f ^ %f = %f' % (num, raiseby, answer)) + return answer def square(self, num): answer = math.pow(num, 2) + print(answer) + return answer def squareroot(self, num): answer = math.sqrt(num) print("Square root (%f) = %f" % (num, answer)) + return answer def inverse(self, num): answer = 1/(num) print('Inverse (%f) = %f' % (num, answer)) + return answer def switchsign(self, num): print(1-(num<=0)) + return answer def sinrad(self, num): answer = math.sin(num) print('Sine (%f) = %f' %(num, answer)) + return answer def cosrad(self, num): answer = math.cos(num) print('Cosine (%f) = %f' %(num, answer)) + return answer def tanrad(self, num): answer = math.tan(num) print('Tangent (%f) = %f' %(num, answer)) + return answer def cosecrad(self, num): answer = 1/(math.sin(num)) print('Inverse Sine(%f) = %f' % (num, answer)) + return answer def secrad(self, num): answer = 1/(math.cos(num)) print('Inverse Cosine(%f) = %f' % (num, answer)) + return answer def cotrad(self, num): answer = 1/(math.tan(num)) print('Inverse Tangent(%f) = %f' % (num, answer)) + return answer def sindeg(self, num): answer = math.sin(math.radians(num)) print('Sin(%f) in Degrees = %f' % (num, answer)) + return answer def cosdeg(self, num): answer = math.cos(math.radians(num)) print('Cos(%f) in Degrees = %f' % (num, answer)) + return answer def tandeg(self, num): answer = math.tan(math.radians(num)) print('Tan(%f) in Degrees = %f' % (num, answer)) + return answer def cosecdeg(self, num): answer = 1/(math.sin(math.radians(num))) print('Inverse Sine(%f) in Degrees = %f' % (num, answer)) + return answer def secdeg(self, num): answer = 1/(math.cos(math.radians(num))) print('Inverse Cosine(%f) in degrees = %f' % (num, answer)) + return answer def cotdeg(self, num): answer = 1/(math.tan(math.radians(num))) print('Inverse Tangent(%f) in degrees = %f' % (num, answer)) + return answer def factorial(self, num): answer = math.factorial(num) print('Factorial (%f) = %f' % (num, answer)) + return answer def ln(self, num): answer = math.log(num) print('Log (%f) = %f' % (num, answer)) + return answer def logten(self, num): answer = math.log10(num) print('Log10(%f) = %f' % (num, answer)) + return answer def logbasex(self, num, x): answer = math.log(num, x) print('Log base (%f)(%f) = %f' % (x, num, answer)) + return answer def pie(self): print('pi = ', math.pi) + return answer def e_constant(self): print('e = ', math.e) + return answer cal = Calculator() + + +def contin(y): + cal = Calculator() + cont = int(input("If you would like to stop type 1\nIf you would like to contine type 2\n")) + if cont == 1: + cal = Calculator() + 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") + elif cont == 2: + fun = int(input("1 : Addition \t\t 2 : Subtraction\n3 : Multiplication \t 4 : Division\n5 : Square root \t 6 : Squared\n")) + contined(fun,y) + else: + print("Sorry try again") + contin(y) + +def contined(picked,y): + if picked == 1: + num2 = int(input("What number would you like to add?\n")) + z = cal.add(int(y),int(num2)) + contin(z) + if picked == 2: + num2 = int(input("What number would you like to subtract?\n")) + z = cal.sub(int(y),int(num2)) + contin(z) + if picked == 3: + num2 = int(input("What number would you like to multiply by?\n")) + z = cal.mul(int(y), int(num2)) + contin(z) + if picked == 4: + num2 = int(input("What number would you like to divide by?\n")) + z = cal.div(int(y), int(num2)) + contin(z) + if picked == 5: + z = cal.squareroot(int(y)) + contin(z) + if picked == 6: + z = cal.square(int(y)) + contin(z) + + + + + print("Scientific calculator") print("List of choice:") print('-' * 20) @@ -103,78 +187,100 @@ def e_constant(self): while True: try: choice = int(input("Enter the number of choice: ")) - except: - print("Enter a valid number: (") + except ValueError: + 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) + x = cal.add(n1, n2) + contin(x) 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) + x = cal.sub(n1, n2) + contin(x) 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) + x = cal.mul(n1, n2) + contin(x) 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) + x = cal.div(n1, n2) + contin(x) elif choice == 5: n = float(input("Enter a number to find its Sine in radians : ")) - cal.sinrad(n) + x = cal.sinrad(n) + contin(x) elif choice == 6: n = float(input("Enter a number to find its Cos in radians : ")) - cal.cosrad(n) + x = cal.cosrad(n) + contin(x) elif choice == 7: n = float(input("Enter a number to find its Tan in radians : ")) - cal.tanrad(n) + x = cal.tanrad(n) + contin(x) elif choice == 8: n = float(input("Enter a number to find its Cosecant in radians : ")) - cal.cosecrad(n) + x = cal.cosecrad(n) + contin(x) elif choice == 9: n = float(input("Enter a number to find its Secant in radians : ")) - cal.secrad(n) + x = cal.secrad(n) + contin(x) elif choice == 10: n = float(input("Enter a number to find its Cot in radians : ")) - cal.cotrad(n) + x = cal.cotrad(n) + contin(x) elif choice == 11: - cal.pie() + x = cal.pie() + contin(x) elif choice == 12: n = float(input("Enter a number to find its Sine in degrees : ")) - cal.sindeg(n) + x = cal.sindeg(n) + contin(x) elif choice == 13: n = float(input("Enter a number to find its Cosine in degrees : ")) - cal.cosdeg(n) + x = cal.cosdeg(n) + contin(x) elif choice == 14: n = float(input("Enter a number to find its Tan in degrees : ")) - cal.tandeg(n) + x = cal.tandeg(n) + contin(x) elif choice == 15: n = float(input("Enter a number to find its Cosecant in degrees : ")) - cal.cosecdeg(n) + x = cal.cosecdeg(n) + contin(x) elif choice == 16: n = float(input("Enter a number to find its Secant in degrees : ")) - cal.secdeg(n) + x = cal.secdeg(n) + contin(x) elif choice == 17: n = float(input("Enter a number to find its Cot in degrees : ")) - cal.cotdeg(n) + x = cal.cotdeg(n) + contin(x) elif choice == 18: n = float(input("Enter a number to find its Natural in log : ")) - cal.ln(n) + x = cal.ln(n) + contin(x) elif choice == 19: n = float(input("Enter a number to find its Base 10 log : ")) - cal.logten(n) + x = cal.logten(n) + contin(x) 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 + x = cal.logbasex(n1, n2) # steps are made like functions + contin(x) elif choice == 21: n = float(input("Enter a number to get it's Square root : ")) - cal.squareroot(n) + x = cal.squareroot(n) + contin(x) elif choice == 22: n1 = float(input("Enter a number : ")) n2 = float(input("Enter its power")) - cal.powerof(n1, n2) + x = cal.powerof(n1, n2) + contin(x) else: print("ERROR : Please enter a valid number ") From 3a90422ab0e7854617959a3c35598fd9c04b3927 Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 00:51:30 -0500 Subject: [PATCH 07/13] invert sign solved --- main-app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main-app.py b/main-app.py index 263839f..0863991 100644 --- a/main-app.py +++ b/main-app.py @@ -134,7 +134,7 @@ def contin(y): print("10 : Cot in radians \t 21 : Square root") print("11 : pi \t\t 22 : Power of") elif cont == 2: - fun = int(input("1 : Addition \t\t 2 : Subtraction\n3 : Multiplication \t 4 : Division\n5 : Square root \t 6 : Squared\n")) + fun = int(input("1 : Addition \t\t 2 : Subtraction\n3 : Multiplication \t 4 : Division\n5 : Square root \t 6 : Squared\n7: Invert Sign")) contined(fun,y) else: print("Sorry try again") @@ -163,6 +163,10 @@ def contined(picked,y): if picked == 6: z = cal.square(int(y)) contin(z) + if picked == 7: + z = y*-1 + print z + contin(z) From 93b97b40498c6116dccf5382adc927720a8267da Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 04:11:14 -0400 Subject: [PATCH 08/13] everything but tests and memory --- main-app.py | 68 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/main-app.py b/main-app.py index 0863991..9daa7db 100644 --- a/main-app.py +++ b/main-app.py @@ -1,5 +1,7 @@ import math +import decimal +mem = 0 class Calculator(object): def add(self, num1, num2): @@ -110,7 +112,6 @@ def e_constant(self): print('e = ', math.e) return answer - cal = Calculator() @@ -118,23 +119,9 @@ def contin(y): cal = Calculator() cont = int(input("If you would like to stop type 1\nIf you would like to contine type 2\n")) if cont == 1: - cal = Calculator() - 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") + switchdisplaymode(y) elif cont == 2: - fun = int(input("1 : Addition \t\t 2 : Subtraction\n3 : Multiplication \t 4 : Division\n5 : Square root \t 6 : Squared\n7: Invert Sign")) + fun = int(input("1 : Addition \t\t 2 : Subtraction\n3 : Multiplication \t 4 : Division\n5 : Square root \t 6 : Squared\n7: Invert Sign\n")) contined(fun,y) else: print("Sorry try again") @@ -145,32 +132,57 @@ def contined(picked,y): num2 = int(input("What number would you like to add?\n")) z = cal.add(int(y),int(num2)) contin(z) - if picked == 2: + elif picked == 2: num2 = int(input("What number would you like to subtract?\n")) z = cal.sub(int(y),int(num2)) contin(z) - if picked == 3: + elif picked == 3: num2 = int(input("What number would you like to multiply by?\n")) z = cal.mul(int(y), int(num2)) contin(z) - if picked == 4: + elif picked == 4: num2 = int(input("What number would you like to divide by?\n")) z = cal.div(int(y), int(num2)) contin(z) - if picked == 5: + elif picked == 5: z = cal.squareroot(int(y)) contin(z) - if picked == 6: + elif picked == 6: z = cal.square(int(y)) contin(z) - if picked == 7: + elif picked == 7: z = y*-1 - print z + print (z) contin(z) +def switchdisplaymode(x): + displaypick = int(input("What display would you like to use?\n 1. Binary\n 2. Octal\n 3. Decimal\n 4. Hexadecimal\n 5. Continue to Memory \n")) + convertdisplay(displaypick,x) +def convertdisplay(l,ber): + ber = int(ber) + if l == 1: + b = bin(ber) + print(b) + switchdisplaymode(ber) + if l == 2: + b = oct(ber) + print(b) + switchdisplaymode(ber) + if l == 3: + b = decimal.Decimal(ber) + print(b) + switchdisplaymode(ber) + if l == 4: + b = hex(ber) + print(b) + switchdisplaymode(ber) + if l == 5: + memory_ask(ber) +def memory_ask(input): + pass print("Scientific calculator") print("List of choice:") @@ -186,6 +198,8 @@ def contined(picked,y): 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(" 23 : To use number stored in memory") +print("MC : to Clear Memory ^C : to Power off ") print('-' * 20) choice = "" while True: @@ -286,5 +300,9 @@ def contined(picked,y): n2 = float(input("Enter its power")) x = cal.powerof(n1, n2) contin(x) + elif choice == "MC": + mem = 0 + elif choice == 23: + memory_use(mem) else: - print("ERROR : Please enter a valid number ") + print("ERROR : Please enter a valid number") From a7e8097626cbc70cc315a271f2130319b6ad1d5b Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 11:40:04 -0400 Subject: [PATCH 09/13] need some tests --- main-app.py | 213 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 188 insertions(+), 25 deletions(-) diff --git a/main-app.py b/main-app.py index 9daa7db..03ac67f 100644 --- a/main-app.py +++ b/main-app.py @@ -180,36 +180,197 @@ def convertdisplay(l,ber): if l == 5: memory_ask(ber) +def memory_clear(): + global mem + mem = 0 + print_options() +def memory_recall(): + global mem + print(str(mem) + " is in memory") + int(mem) + print_options() -def memory_ask(input): - pass +def print_options(): + 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("MRC : To recall memory M+ : To use number stored in memory") + print("MC : to Clear Memory ^C : to Power off ") + print('-' * 20) -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(" 23 : To use number stored in memory") -print("MC : to Clear Memory ^C : to Power off ") -print('-' * 20) + +def memory_ask(x): + response = input("Would you like to stor this number in memory? Y/N\n") + if response == "Y": + global mem + mem = x + print_options() + elif response== "N": + cal = Calculator() + print_options() + else: + memory_ask(x) + + + + +def memory_use(memory): + global mem + print(str(mem) + " in memory") + mem = int(mem) + choice = "" + print_options() + choice = "" + while True: + try: + choice = input("Enter the number of choice: ") + if choice == "MC" or choice == "M+" or choice == "MRC": + str(choice) + else: + choice = int(choice) + except ValueError: + print("Enter a valid number: ") + if choice == 1: + n2 = float(input("Enter the second number to add : ")) + x = cal.add(mem, n2) + contin(x) + elif choice == 2: + n1 = memory + n2 = float(input("Enter the second number to subtract : ")) + x = cal.sub(n1, n2) + contin(x) + elif choice == 3: + n1 = memory + n2 = float(input("Enter the second number to multiply : ")) + x = cal.mul(n1, n2) + contin(x) + elif choice == 4: + n1 = memory + n2 = float(input("Enter the second number for division : ")) + x = cal.div(n1, n2) + contin(x) + elif choice == 5: + n = memory + x = cal.sinrad(n) + contin(x) + elif choice == 6: + n = memory + x = cal.cosrad(n) + contin(x) + elif choice == 7: + n = memory + x = cal.tanrad(n) + contin(x) + elif choice == 8: + n = memory + x = cal.cosecrad(n) + contin(x) + elif choice == 9: + n = memory + x = cal.secrad(n) + contin(x) + elif choice == 10: + n = memory + x = cal.cotrad(n) + contin(x) + elif choice == 11: + x = cal.pie() + contin(x) + elif choice == 12: + n = memory + x = cal.sindeg(n) + contin(x) + elif choice == 13: + n = memory + x = cal.cosdeg(n) + contin(x) + elif choice == 14: + n = memory + x = cal.tandeg(n) + contin(x) + elif choice == 15: + n = memory + x = cal.cosecdeg(n) + contin(x) + elif choice == 16: + n = memory + x = cal.secdeg(n) + contin(x) + elif choice == 17: + n = memory + x = cal.cotdeg(n) + contin(x) + elif choice == 18: + n = memory + x = cal.ln(n) + contin(x) + elif choice == 19: + n = memory + x = cal.logten(n) + contin(x) + elif choice == 20: + n1 = memory + n2 = float(input("Enter a number to find its log to the given log value : ")) + x = cal.logbasex(n1, n2) # steps are made like functions + contin(x) + elif choice == 21: + n = memory + x = cal.squareroot(n) + contin(x) + elif choice == 22: + n1 = memory + n2 = float(input("Enter its power")) + x = cal.powerof(n1, n2) + contin(x) + elif choice == 23: + memory_use(mem) + else: + print("ERROR : Please enter a valid number") + + +def first_ask(funct): + num1 = int(input("What is the first number for " + funct + "\n")) + if type(num1) == int: + return num1 + else: + first_ask(funct) + +def second_ask(funct): + num2 = int(input("What is the second number for " + funct + "\n")) + if type(num2) == int: + return num2 + else: + second_ask(funct) + +def one_variable_ask(funct): + + + +print_options() choice = "" while True: try: - choice = int(input("Enter the number of choice: ")) + choice = input("Enter the number of choice: ") + if choice == "MC" or choice == "M+" or choice == "MRC": + pass + else: + choice = int(choice) except ValueError: 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 : ")) + addition_string = "addition" + n1 = first_ask(addition_string) + n2 = second_ask(addition_string) x = cal.add(n1, n2) contin(x) elif choice == 2: @@ -289,7 +450,7 @@ def memory_ask(input): elif choice == 20: n1 = float(input("Enter base value : ")) n2 = float(input("Enter a number to find its log to the given log value : ")) - x = cal.logbasex(n1, n2) # steps are made like functions + x = cal.logbasex(n1, n2) contin(x) elif choice == 21: n = float(input("Enter a number to get it's Square root : ")) @@ -301,8 +462,10 @@ def memory_ask(input): x = cal.powerof(n1, n2) contin(x) elif choice == "MC": - mem = 0 - elif choice == 23: + memory_clear() + elif choice == "M+": memory_use(mem) + elif choice == "MRC": + memory_recall() else: print("ERROR : Please enter a valid number") From 70639b024c6657f6413d98820f5b6b80790bd0da Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:18:41 -0400 Subject: [PATCH 10/13] need tests --- main-app.py | 142 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 45 deletions(-) diff --git a/main-app.py b/main-app.py index 03ac67f..fd6f9ce 100644 --- a/main-app.py +++ b/main-app.py @@ -129,19 +129,23 @@ def contin(y): def contined(picked,y): if picked == 1: - num2 = int(input("What number would you like to add?\n")) + x = input("What number would you like to add?\n") + num2 = test_answer(x,"add", "next") z = cal.add(int(y),int(num2)) contin(z) elif picked == 2: - num2 = int(input("What number would you like to subtract?\n")) + x = input("What number would you like to add?\n") + num2 = test_answer(x, "subtract", "next") z = cal.sub(int(y),int(num2)) contin(z) elif picked == 3: - num2 = int(input("What number would you like to multiply by?\n")) + x = input("What number would you like to multiply by?\n") + num2 = test_answer(x, "multiply by", "next") z = cal.mul(int(y), int(num2)) contin(z) elif picked == 4: - num2 = int(input("What number would you like to divide by?\n")) + x = input("What number would you like to add?\n") + num2 = test_answer(x, "divide by", "next") z = cal.div(int(y), int(num2)) contin(z) elif picked == 5: @@ -337,22 +341,22 @@ def memory_use(memory): else: print("ERROR : Please enter a valid number") +def test_answer(x, funct, place): + condition = False + while condition == False: + try: + x = float(x) + except ValueError: + print("Error: Please Enter Valid number") + x = input("Enter " + place + " number to" + funct + ":\n") + condition = True + return float(x) + + + -def first_ask(funct): - num1 = int(input("What is the first number for " + funct + "\n")) - if type(num1) == int: - return num1 - else: - first_ask(funct) -def second_ask(funct): - num2 = int(input("What is the second number for " + funct + "\n")) - if type(num2) == int: - return num2 - else: - second_ask(funct) -def one_variable_ask(funct): @@ -366,99 +370,147 @@ def one_variable_ask(funct): else: choice = int(choice) except ValueError: - print("Enter a valid number: ") + print("ERROR : Please enter a valid number") if choice == 1: - addition_string = "addition" - n1 = first_ask(addition_string) - n2 = second_ask(addition_string) + function_string = "add" + z = input("Enter the first number to add : ") + n1 = test_answer(z,function_string,"first") + y = input("Enter the second number to add : ") + n2 = test_answer(y,function_string, "second") x = cal.add(n1, n2) contin(x) elif choice == 2: - n1 = float(input("Enter the first number to subtract : ")) - n2 = float(input("Enter the second number to subtract : ")) + function_string = "subtract" + z = input("Enter the first number in subtraction : ") + n1 = test_answer(z, function_string, "first") + y = input("Enter the second number in subraction : ") + n2 = test_answer(y, function_string, "second") x = cal.sub(n1, n2) contin(x) elif choice == 3: - n1 = float(input("Enter the first number to multiply : ")) - n2 = float(input("Enter the second number to multiply : ")) + function_string = "multiply by" + z = input("Enter the first number to " + function_string+ " : ") + n1 = test_answer(z, function_string, "first") + y = input("Enter the second number number to " + function_string+ " : ") + n2 = test_answer(y, function_string, "second") x = cal.mul(n1, n2) contin(x) elif choice == 4: - n1 = float(input("Enter the first number for division : ")) - n2 = float(input("Enter the second number for division : ")) + function_string = "divide by" + z = input("Enter the first number to " + function_string + " : ") + n1 = test_answer(z, function_string, "first") + y = input("Enter the second number number to " + function_string + " : ") + n2 = test_answer(y, function_string, "second") x = cal.div(n1, n2) contin(x) elif choice == 5: - n = float(input("Enter a number to find its Sine in radians : ")) + function_string = "find Sine its in Radian" + z = input("Enter a number to "+ function_string + " : ") + n = test_answer(z,function_string,"") x = cal.sinrad(n) contin(x) elif choice == 6: - n = float(input("Enter a number to find its Cos in radians : ")) + function_string = "find its Cos in radians" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cosrad(n) contin(x) elif choice == 7: - n = float(input("Enter a number to find its Tan in radians : ")) + function_string = "find its Tan in radians" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.tanrad(n) contin(x) elif choice == 8: - n = float(input("Enter a number to find its Cosecant in radians : ")) + function_string = "find its Cosecant in radians" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cosecrad(n) contin(x) elif choice == 9: - n = float(input("Enter a number to find its Secant in radians : ")) + function_string = "find its Secant in radians" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.secrad(n) contin(x) elif choice == 10: - n = float(input("Enter a number to find its Cot in radians : ")) + function_string = "find its Cot in radians" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cotrad(n) contin(x) elif choice == 11: x = cal.pie() contin(x) elif choice == 12: - n = float(input("Enter a number to find its Sine in degrees : ")) + function_string = "find its Sine in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.sindeg(n) contin(x) elif choice == 13: - n = float(input("Enter a number to find its Cosine in degrees : ")) + function_string = "find its Cosine in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cosdeg(n) contin(x) elif choice == 14: - n = float(input("Enter a number to find its Tan in degrees : ")) + function_string = "find its Tan in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.tandeg(n) contin(x) elif choice == 15: - n = float(input("Enter a number to find its Cosecant in degrees : ")) + function_string = "find its Cosecant in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cosecdeg(n) contin(x) elif choice == 16: - n = float(input("Enter a number to find its Secant in degrees : ")) + function_string = "find its Secant in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.secdeg(n) contin(x) elif choice == 17: - n = float(input("Enter a number to find its Cot in degrees : ")) + function_string = "find its Cot in degrees" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.cotdeg(n) contin(x) elif choice == 18: - n = float(input("Enter a number to find its Natural in log : ")) + function_string = "find its Natural in log" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.ln(n) contin(x) elif choice == 19: - n = float(input("Enter a number to find its Base 10 log : ")) + function_string = "find its Base 10 log" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.logten(n) contin(x) elif choice == 20: - n1 = float(input("Enter base value : ")) - n2 = float(input("Enter a number to find its log to the given log value : ")) + z = input("Enter base value : ") + n1 = test_answer(z, "use as base value", "") + y = input("Enter a number to find its log to the given log value : ") + n2 = test_answer(y, "to serve as the exponent in log function", "") + x = cal.div(n1, n2) x = cal.logbasex(n1, n2) contin(x) elif choice == 21: - n = float(input("Enter a number to get it's Square root : ")) + function_string = "find its square root" + z = input("Enter a number to " + function_string + " : ") + n = test_answer(z, function_string, "") x = cal.squareroot(n) contin(x) elif choice == 22: n1 = float(input("Enter a number : ")) n2 = float(input("Enter its power")) + z = input("Enter base value : ") + n1 = test_answer(z, "use as base value", "") + y = input("Enter a number to serve as exponent : ") + n2 = test_answer(y, "Enter a number to serve as exponent", "") x = cal.powerof(n1, n2) contin(x) elif choice == "MC": @@ -468,4 +520,4 @@ def one_variable_ask(funct): elif choice == "MRC": memory_recall() else: - print("ERROR : Please enter a valid number") + pass From ca01143f8108b6a3a212ff6fbcb915779e5892d6 Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 16:18:14 -0400 Subject: [PATCH 11/13] done --- main-app.py | 232 +++++++++++++++++++++++++++------------------------- 1 file changed, 120 insertions(+), 112 deletions(-) diff --git a/main-app.py b/main-app.py index fd6f9ce..5e108ef 100644 --- a/main-app.py +++ b/main-app.py @@ -235,121 +235,130 @@ def memory_use(memory): choice = "" print_options() choice = "" - while True: - try: - choice = input("Enter the number of choice: ") - if choice == "MC" or choice == "M+" or choice == "MRC": - str(choice) - else: - choice = int(choice) - except ValueError: - print("Enter a valid number: ") - if choice == 1: - n2 = float(input("Enter the second number to add : ")) - x = cal.add(mem, n2) - contin(x) - elif choice == 2: - n1 = memory - n2 = float(input("Enter the second number to subtract : ")) - x = cal.sub(n1, n2) - contin(x) - elif choice == 3: - n1 = memory - n2 = float(input("Enter the second number to multiply : ")) - x = cal.mul(n1, n2) - contin(x) - elif choice == 4: - n1 = memory - n2 = float(input("Enter the second number for division : ")) - x = cal.div(n1, n2) - contin(x) - elif choice == 5: - n = memory - x = cal.sinrad(n) - contin(x) - elif choice == 6: - n = memory - x = cal.cosrad(n) - contin(x) - elif choice == 7: - n = memory - x = cal.tanrad(n) - contin(x) - elif choice == 8: - n = memory - x = cal.cosecrad(n) - contin(x) - elif choice == 9: - n = memory - x = cal.secrad(n) - contin(x) - elif choice == 10: - n = memory - x = cal.cotrad(n) - contin(x) - elif choice == 11: - x = cal.pie() - contin(x) - elif choice == 12: - n = memory - x = cal.sindeg(n) - contin(x) - elif choice == 13: - n = memory - x = cal.cosdeg(n) - contin(x) - elif choice == 14: - n = memory - x = cal.tandeg(n) - contin(x) - elif choice == 15: - n = memory - x = cal.cosecdeg(n) - contin(x) - elif choice == 16: - n = memory - x = cal.secdeg(n) - contin(x) - elif choice == 17: - n = memory - x = cal.cotdeg(n) - contin(x) - elif choice == 18: - n = memory - x = cal.ln(n) - contin(x) - elif choice == 19: - n = memory - x = cal.logten(n) - contin(x) - elif choice == 20: - n1 = memory - n2 = float(input("Enter a number to find its log to the given log value : ")) - x = cal.logbasex(n1, n2) # steps are made like functions - contin(x) - elif choice == 21: - n = memory - x = cal.squareroot(n) - contin(x) - elif choice == 22: - n1 = memory - n2 = float(input("Enter its power")) - x = cal.powerof(n1, n2) - contin(x) - elif choice == 23: - memory_use(mem) + try: + choice = input("Enter the number of choice: ") + if choice == "MC" or choice == "M+" or choice == "MRC": + str(choice) else: - print("ERROR : Please enter a valid number") + choice = int(choice) + except ValueError: + print("Enter a valid number: ") + if choice == 1: + y = input("Enter the second number to add : ") + n2 = test_answer(y, "to add", "second") + x = cal.add(mem, n2) + contin(x) + elif choice == 2: + n1 = mem + y = input("Enter the second number to subtract : ") + n2 = test_answer(y, "to subtract", "second") + x = cal.sub(mem, n2) + contin(x) + elif choice == 3: + n1 = mem + y = input("Enter the second number to multiply : ") + n2 = test_answer(y,"to multiply","second") + x = cal.mul(mem, n2) + contin(x) + elif choice == 4: + n1 = memory + y = input("Enter the second number for division : ") + n2 = test_answer(y,"for division", "second") + x = cal.div(mem, n2) + contin(x) + elif choice == 5: + n = mem + x = cal.sinrad(n) + contin(x) + elif choice == 6: + n = memory + x = cal.cosrad(n) + contin(x) + elif choice == 7: + n = memory + x = cal.tanrad(n) + contin(x) + elif choice == 8: + n = memory + x = cal.cosecrad(n) + contin(x) + elif choice == 9: + n = memory + x = cal.secrad(n) + contin(x) + elif choice == 10: + n = memory + x = cal.cotrad(n) + contin(x) + elif choice == 11: + x = cal.pie() + contin(x) + elif choice == 12: + n = memory + x = cal.sindeg(n) + contin(x) + elif choice == 13: + n = memory + x = cal.cosdeg(n) + contin(x) + elif choice == 14: + n = memory + x = cal.tandeg(n) + contin(x) + elif choice == 15: + n = memory + x = cal.cosecdeg(n) + contin(x) + elif choice == 16: + n = memory + x = cal.secdeg(n) + contin(x) + elif choice == 17: + n = memory + x = cal.cotdeg(n) + contin(x) + elif choice == 18: + n = memory + x = cal.ln(n) + contin(x) + elif choice == 19: + n = memory + x = cal.logten(n) + contin(x) + elif choice == 20: + n1 = memory + n2 = input("Enter a number to find its log to this given log value : ") + x = cal.logbasex(n1, n2) # steps are made like functions + contin(x) + elif choice == 21: + n = memory + x = cal.squareroot(n) + contin(x) + elif choice == 22: + n1 = memory + y = input("Enter a number to serve as exponent : ") + n2 = test_answer(y, "Enter a number to serve as exponent", "") + x = cal.powerof(n1, n2) + int(x) + contin(x) + elif choice == "MC": + memory_clear() + elif choice == "M+": + mem + int(mem) + memory_use(mem) + elif choice == "MRC": + memory_recall() + else: + print("ERROR : Please enter a valid number") def test_answer(x, funct, place): - condition = False - while condition == False: + while type(x) == str: try: x = float(x) except ValueError: print("Error: Please Enter Valid number") - x = input("Enter " + place + " number to" + funct + ":\n") - condition = True + x = input("Enter " + place + " number to " + funct + ":\n") return float(x) @@ -493,9 +502,8 @@ def test_answer(x, funct, place): elif choice == 20: z = input("Enter base value : ") n1 = test_answer(z, "use as base value", "") - y = input("Enter a number to find its log to the given log value : ") + n2 = input("Enter a number to find its log to this given log value : ") n2 = test_answer(y, "to serve as the exponent in log function", "") - x = cal.div(n1, n2) x = cal.logbasex(n1, n2) contin(x) elif choice == 21: @@ -505,8 +513,6 @@ def test_answer(x, funct, place): x = cal.squareroot(n) contin(x) elif choice == 22: - n1 = float(input("Enter a number : ")) - n2 = float(input("Enter its power")) z = input("Enter base value : ") n1 = test_answer(z, "use as base value", "") y = input("Enter a number to serve as exponent : ") @@ -516,6 +522,8 @@ def test_answer(x, funct, place): elif choice == "MC": memory_clear() elif choice == "M+": + mem + int(mem) memory_use(mem) elif choice == "MRC": memory_recall() From 2876973ebc6d50f5e58e44506ae21def1b539de8 Mon Sep 17 00:00:00 2001 From: JKocher13 <61708469+JKocher13@users.noreply.github.com> Date: Sun, 8 Mar 2020 23:01:58 -0400 Subject: [PATCH 12/13] finsihed --- .DS_Store | Bin 6148 -> 6148 bytes __init__.py | 0 calctests.py | 162 ++++++++++++++++++++++++++++++++++++++++++++++---- calculator.py | 84 -------------------------- display.py | 99 ------------------------------ main-app.py | 6 +- 6 files changed, 154 insertions(+), 197 deletions(-) delete mode 100644 __init__.py delete mode 100644 calculator.py delete mode 100644 display.py diff --git a/.DS_Store b/.DS_Store index 6826a9eace4fe1984ff3ca8723e35be32ad9d137..9a7e72eb3cb871701405d77088d598c235412efe 100644 GIT binary patch delta 87 zcmZoMXfc=|#>B`mu~2NHo}wrV0|Nsi1A_nqLo!1m5N9x?GQ>|TT+YZc*@>xevm)~| mmdy*8moRQ-=iui6YTG=K`8)Guei2I!phl2Rrp*B&TbKb$loKuh delta 266 zcmZoMXfc=|#>B)qu~2NHo}wr_0|Nsi1A_nqLncEBLp%`bF%)cm$he%*93;gJ7RqGE zLzZT!^vuamPRhwo0;&M&WUvNejsIZ4z%ZGIv9O+(A( Date: Fri, 27 Mar 2020 07:16:02 -0400 Subject: [PATCH 13/13] calc updated --- .DS_Store | Bin 6148 -> 6148 bytes __init__.py | 0 calculator.py | 108 ++++ main-app.py | 863 +++++++++++++------------------ calctests.py => test_main-app.py | 130 +---- 5 files changed, 474 insertions(+), 627 deletions(-) create mode 100644 __init__.py create mode 100644 calculator.py rename calctests.py => test_main-app.py (54%) diff --git a/.DS_Store b/.DS_Store index 9a7e72eb3cb871701405d77088d598c235412efe..14de59564c651d153e02c3d1200bc455a54113fd 100644 GIT binary patch delta 281 zcmZoMXfc=|#>B)qu~2NHo}wr_0|Nsi1A_nqLncEBLp%`bF%)cm$he%*93;gJ7RqGE zLzZT!^vuamPRhwo0;&M&WN-%J_Ww{YnTJuAQGc=(qmc*0TA;)%m;{i`%aF{F$dCgh zOMzq}(8hd*B9M*fMl$XLsy2h^oLt4I!N*tt6v~GSZD7>T_YK#v1C-B`mu~2NHo}wrV0|Nsi1A_nqLo!1m5N9x?GQ>|TT+YZc*@;P)QDbre zlaUakI8c?we=q>D7#O%GCorq