Skip to content
Open
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__pycache__/
*.py[cod]
.pytest_cache/
.coverage
htmlcov/
*.exe
caeser_test
40 changes: 21 additions & 19 deletions Learning/Part-1/Python/calcfinalq2.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,24 @@ def select_op(choice):
print("Unrecognized operation")
c1 = 0
hist = []
while True:
print("Select operation.")
print("1.Add : + ")
print("2.Subtract : - ")
print("3.Multiply : * ")
print("4.Divide : / ")
print("5.Power : ^ ")
print("6.Remainder: % ")
print("7.Terminate: # ")
print("8.Reset : $ ")
print("8.History : ? ")
# take input from the user
choice = input("Enter choice(+,-,*,/,^,%,#,$,?): ")
print(choice)
c1 +=1
if(select_op(choice) == -1):
#program ends here
print("Done. Terminating")
exit()

if __name__ == "__main__":
while True:
print("Select operation.")
print("1.Add : + ")
print("2.Subtract : - ")
print("3.Multiply : * ")
print("4.Divide : / ")
print("5.Power : ^ ")
print("6.Remainder: % ")
print("7.Terminate: # ")
print("8.Reset : $ ")
print("8.History : ? ")
# take input from the user
choice = input("Enter choice(+,-,*,/,^,%,#,$,?): ")
print(choice)
c1 +=1
if(select_op(choice) == -1):
#program ends here
print("Done. Terminating")
exit()
24 changes: 24 additions & 0 deletions Learning/Part-1/Python/test_calcfinalq2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
from calcfinalq2 import add

class TestCalcAdd(unittest.TestCase):
def test_add_positive_numbers(self):
self.assertEqual(add(5, 3), 8)
self.assertEqual(add(10.5, 2.5), 13.0)

def test_add_negative_numbers(self):
self.assertEqual(add(-5, -3), -8)
self.assertEqual(add(-10.5, -2.5), -13.0)

def test_add_mixed_numbers(self):
self.assertEqual(add(5, -3), 2)
self.assertEqual(add(-10, 5), -5)
self.assertEqual(add(10.5, -2.5), 8.0)

def test_add_zero(self):
self.assertEqual(add(5, 0), 5)
self.assertEqual(add(0, -3), -3)
self.assertEqual(add(0, 0), 0)

if __name__ == '__main__':
unittest.main()