Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
466a9f7
Create Display functions
Nate-Ingram-Jr Feb 28, 2026
90bc2dc
change to .py
dburcat Feb 28, 2026
ffce5ce
Subtraction corrected. Multiplication and Addition created.
James-Taylor-JJ Feb 28, 2026
6741de2
Added exponentiation and square roots.
James-Taylor-JJ Feb 28, 2026
a561363
Added Inversion and Negation.
James-Taylor-JJ Feb 28, 2026
31224ed
Added Sine, Cosine, Tangent, and each of their inverses.
James-Taylor-JJ Feb 28, 2026
560eb9f
Corrected syntax on trigonmetric functions and their inverses (sine, …
James-Taylor-JJ Feb 28, 2026
3c93184
Created display modes to switch between for Binary, Hexadecimal, deci…
Nate-Ingram-Jr Feb 28, 2026
a536509
Added code for Base10 Logarithm, Natural Logarithm, and Inverse Natur…
James-Taylor-JJ Feb 28, 2026
361522e
Test push with Paul
James-Taylor-JJ Feb 28, 2026
cb274a4
Merge branch 'master' of https://github.com/Gilbertlittlefinger/SciCa…
James-Taylor-JJ Feb 28, 2026
305dba4
Add two required auxiliary functions: Infinity and Absolute Value
James-Taylor-JJ Mar 1, 2026
6c78a57
Added terminal clean up and spacing. Added clear operation.
dburcat Mar 1, 2026
934b7b5
Added math operator code to main-app.py
James-Taylor-JJ Mar 1, 2026
9266c27
Added operation format look for equation
dburcat Mar 1, 2026
55f4af3
Corrected method for Infinity feature.
James-Taylor-JJ Mar 1, 2026
9b29ef4
Added trigonemtric functions to switch between degrees and radian
Nate-Ingram-Jr Mar 1, 2026
9a88922
Added trig displace switching
dburcat Mar 1, 2026
edf4fbe
Committed Memory history additions to recall more than a single calcu…
Nate-Ingram-Jr Mar 1, 2026
c93dd94
Add history recall method and divide by zero error continue
dburcat Mar 1, 2026
e04ecd2
Changed wording of Division error, it's not that dividing by 0 isn't …
Nate-Ingram-Jr Mar 1, 2026
e00312c
Added continue from error cases in main-app.py for division by zero, …
dburcat Mar 1, 2026
44ab8ad
Simplified using history in operations by using one fuction callout w…
dburcat Mar 1, 2026
577470f
Fixed string statement
dburcat Mar 1, 2026
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
124 changes: 124 additions & 0 deletions Display_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import time

class Display:
def store_memory(self, value, memory_value, current_result):
# Code to store the value in memory
if value.lower() == "m+":
memory_value = current_result
print(f"\nCurrent memory value: {memory_value}", end="")
elif value.lower() == "mc":
memory_value = 0
print(f"\nCurrent memory value: {memory_value}", end="")
elif value.lower() == "mrc":
print(f"\nCurrent memory value: {memory_value}", end="")
return memory_value

def memory_history(self, value, history_value):
history_value.append(value)

def display_history(self, value, history_value):
if value.lower() == "h":
print("\nMemory history:", end="")
print(history_value, end="")
elif value.lower() == "hc":
history_value.clear()
print("\nMemory history cleared.", end="")

def history_call(self, value, history_value):
if value < 0 or value >= len(history_value):
print("\nInvalid history index. Please try again.")
return None
else:
return history_value[value]


def trig_display(self, mode, switch):
# Code to display trigonometric results in the correct mode
if mode.lower() == "degree":
print("\nDisplaying result in degree mode.", end="")
return mode.lower()
elif mode.lower() == "radian":
print("\nDisplaying result in radian mode.", end="")
return mode.lower()
else:
return switch.lower() # Return the current display mode if no switch command is given

def auto_trig_display(self, switch):
# Code to automatically switch trigonometric display mode based on the current mode
if switch == "degree":
print("\nDisplaying result in radian mode.", end="")
return "radian"
elif switch == "radian":
print("\nDisplaying result in degree mode.", end="")
return "degree"
else:
return switch # Return the current display mode if no auto switch is defined

def switch_display_mode(self, mode, switch):
# Code to switch display mode
if mode.lower() == "hexadecimal":
print("\nSwitched to hexadecimal display mode.", end="")
return mode.lower()
elif mode.lower() == "binary":
print("\nSwitched to binary display mode.", end="")
return mode.lower()
elif mode.lower() == "decimal":
print("\nSwitched to decimal display mode.", end="")
return mode.lower()
elif mode.lower() == "octal":
print("\nSwitched to octal display mode.", end="")
return mode.lower()
else:
return switch.lower() # Return the current display mode if no switch command is given

def auto_display_mode(self, switch):
# Code to automatically switch display mode based on the result
if switch == "hexadecimal":
print("\nDisplaying result in binary display mode.", end="")
return "binary"
elif switch == "binary":
print("\nDisplaying result in octal display mode.", end="")
return "octal"
elif switch == "octal":
print("\nDisplaying result in decimal display mode.", end="")
return "decimal"
elif switch == "decimal":
print("\nDisplaying result in hexadecimal display mode.", end="")
return "hexadecimal"

else:
return switch # Return the current display mode if no auto switch is defined


def self_destruct(self):
# Code to simulate self destruct sequence and exit the program
time.sleep(0.5)
print("Self destruct sequence initiated. \n Loading self_destruct.exe... \n initating count down sequence...")
time.sleep(1)
print("3...")
time.sleep(1)
print("2...")
time.sleep(1)
print("1...")
time.sleep(1)
print("\033[2J\033[H", end="")
print("\nBOOM! \n Error: self_destruct.exe has caused a fatal error \n Initiating backup restoration and kill command...")

for i in range(3):
time.sleep(2)
print("\nLoading...", end="")

print("\033[2J\033[H", end="")
print("\n\nBackup restoration complete. \n Kill command successful. \n Exiting program...")
print("Have a nice day")
exit()

def display_clear(self, value):
# Code to clear the display
if value.lower() == "clear":
print("\033[2J\033[H", end="") # ANSI escape codes to clear the terminal screen

def display_quitcancel(self):
# Code to display quit cancel message and return to previous state
print("\nReturning to previous state. Please wait...")
time.sleep(1)
91 changes: 91 additions & 0 deletions calctests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import unittest
from calculator import Calculator

Expand All @@ -20,6 +21,96 @@ def test_sub(self):
c = Calculator()
self.assertEqual(c.sub(9, 3), 6)

def test_mult(self):
c = Calculator()
self.assertEqual(c.mult(9, 3), 27)

def test_div(self):
c = Calculator()
self.assertEqual(c.div(9, 3), 3)

def test_div(self):
c = Calculator()
self.assertEqual(c.sqr(9), 81)

def test_root2(self):
c = Calculator()
self.assertEqual(c.root2(9), 3)

def test_exp(self):
c = Calculator()
self.assertEqual(c.exp(9,3), 729)

def inv(self):
c = Calculator()
self.assertEqual(c.inv(5), .2)

def neg(self):
c = Calculator()
self.assertEqual(c.neg(9), -9)

def neg(self):
c = Calculator()
self.assertEqual(c.neg(-9), 9)

def sin(self):
c = Calculator()
self.assertEqual(c.sin(9), 0.4121184852417566)

def cos(self):
c = Calculator()
self.assertEqual(c.cos(9), -0.9111302618846769)

def tan(self):
c = Calculator()
self.assertEqual(c.tan(9), 0.4523156594418099)

def isin(self):
c = Calculator()
self.assertEqual(c.isin(-1), -1.5707963267948966)

def icos(self):
c = Calculator()
self.assertEqual(c.icos(-1), 3.141592653589793)

def itan(self):
c = Calculator()
self.assertEqual(c.itan(-1), -0.7853981633974483)

def deg(self):
c = Calculator()
self.assertEqual(c.deg(45), 2578.3100780887044)

def rad(self):
c = Calculator()
self.assertEqual(c.rad(45), 0.7853981633974483)

def fac(self):
c = Calculator()
self.assertEqual(c.fac(9), 362880)

def log(self):
c = Calculator()
self.assertEqual(c.log(9), 2.1972245773362196)

def log10(self):
c = Calculator()
self.assertEqual(c.log10(9), 0.9542425094393249)

def natlog(self):
c = Calculator()
self.assertEqual(c.natlog(9), 2.302585092994046)

def in_natlog(self):
c = Calculator()
self.assertEqual(c.in_natlog(9), 0.43429448190325176)

def infinity(self):
c = Calculator()
self.assertEqual(c.infinity(9),NaN)

def abs_val(self):
c = Calculator()
self.assertEqual(c.abs_val(-9),9)
if __name__ == '__main__':
unittest.main()
89 changes: 88 additions & 1 deletion calculator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import math

class Calculator:

def __init__(self):
Expand All @@ -7,6 +9,91 @@ def add(self, x, y):
return x + y

def sub(self, x, y):
return 0
return x - y

def mult(self, x, y):
return x * y

def div(self, x, y):
if y == 0:
print("\nError: Division by zero is not defined.", end="")
return None
else:
return x / y

def sqr(self, x):
return x * x

def root2(self, x):
if x < 0:
print("\nError: Square root of a negative number is not defined in the real number system.", end="")
return None
else:
return math.sqrt(x)

def exp(self, x, y):
return math.pow(x, y)

def inv(self, x):
return x ** -1

def neg(self, x):
return x * -1

def sin(self, x):
return math.sin(x)

def cos(self, x):
return math.cos(x)

def tan(self, x):
return math.tan(x)

def isin(self, x):
return math.asin(x)

def icos(self, x):
return math.acos(x)

def itan(self, x):
return math.atan(x)

def deg(self, x):
return math.degrees(x)

def rad(self, x):
return math.radians(x)

def fac(self, x):
return math.factorial(x)

def log(self, x):
if x <= 0:
print("\nError: Logarithm of non-positive numbers is not defined.", end="")
return None
else:
return math.log(x)

def log10(self, x):
if x <= 0:
print("\nError: Logarithm of non-positive numbers is not defined.", end="")
return None
else:
return math.log10(x)

def natlog(self, x):
return math.log1p(x)

def in_natlog(self, x):
if x <= 0:
print("\nError: Inverse logarithm of numbers less than or equal to 0 is not defined.", end="")
return None
else:
return math.pow(math.log1p(x),-1)

def infinity(self, x):
return math.isfinite(x)

def abs_val(self, x):
return math.fabs(x)
# add lots more methods to this calculator class.
Loading