-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerald
committed
Dec 2, 2020
0 parents
commit de41af8
Showing
6 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
print("Hello!") | ||
|
||
|
||
print("this is the edited branch") | ||
|
||
|
||
print("This is the addon for feature 1") | ||
|
||
print("i am adding this line!!!") | ||
|
||
print("Hello this is adding new feature1") | ||
|
||
#add new comment | ||
|
Binary file added
BIN
+1.77 KB
__pycache__/test_my_calculator_functions_addition.cpython-37-pytest-6.1.2.pyc
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from my_calculator_functions import * | ||
|
||
class MyCalculator(object): | ||
|
||
def __init__(self): | ||
self._answer = 0.0 | ||
|
||
|
||
def last_answer(self): | ||
return self._answer | ||
|
||
def do_math(self, *arg, function): | ||
self._answer = function(*arg) | ||
return self._answer | ||
|
||
|
||
def add(self, *arg): | ||
return self.do_math(*arg, add) | ||
|
||
def subtract(self, *arg): | ||
return self.do_math(*arg, subtract) | ||
|
||
def multiply(self, *arg): | ||
return self.do_math(*arg, multiply) | ||
|
||
def divide(self, *arg): | ||
return self.do_math(*arg, divide) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
def add(*arg): | ||
if(len(arg)>10): | ||
print("this is another easter") | ||
return "Error: >10 Values" | ||
|
||
|
||
if(len(arg) > 10): | ||
print("Error >10 values given!") | ||
return "Error: >10 Values" | ||
|
||
print("Adding",len(arg),"numbers") | ||
result = 0 | ||
for n in arg: | ||
result = result + n | ||
|
||
print("Add result is", result) | ||
return result | ||
|
||
def subtract(*arg): | ||
if(len(arg) > 10): | ||
print("Error >10 values given!") | ||
return "Error: >10 Values" | ||
print("Subtracting",len(arg),"numbers") | ||
result = arg[0] | ||
for n in range(1, len(arg)): | ||
result = result - arg[n] | ||
|
||
print("Subtract result is", result) | ||
return result | ||
|
||
def multiply(*arg): | ||
if(len(arg) > 10): | ||
print("Error >10 values given!") | ||
return "Error: >10 Values" | ||
print("Multipling",len(arg),"numbers") | ||
result = arg[0] | ||
for n in range(1, len(arg)): | ||
result = result * arg[n] | ||
|
||
print("Multiply result is", result) | ||
return result | ||
|
||
def divide(*arg): | ||
if(len(arg) > 10): | ||
print("Error >10 values given!") | ||
return "Error: >10 Values" | ||
print("Dividing", len(arg),"numbers") | ||
|
||
result = arg[0] | ||
try: | ||
for n in range(1, len(arg)): | ||
result = result / arg[n] | ||
|
||
print("Divide result is", result) | ||
return result | ||
except ZeroDivisionError: | ||
print("Division by Zero Error at number", n+1) | ||
return ZeroDivisionError | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from mycalculator.my_calculator_functions import * | ||
|
||
''' | ||
@pytest.mark.parametrize("a,b,result",[(1,2,3), (2,4,6)]) | ||
def test_add(a,b,result): | ||
value = add(a,b) | ||
assert value == result | ||
def test_add_negative_positive(): | ||
value = add(-1,2,3) | ||
assert value == 4 | ||
def test_add_negative_negative(): | ||
value = add(-1,-2) | ||
assert value == -5 | ||
''' | ||
|
||
def test_over_ten_variables():#add comment | ||
value = add(1,2,3,4,5,6,7,8,9,10,11,12) | ||
assert value == "Error: >10 Values" | ||
|
||
def test_multiplication(): | ||
value = multiply(1,1,1,1,1,1,1,1,1,1) | ||
assert value == 1 | ||
|
||
def test_multiplication_over_ten(): | ||
value = multiply(1,1,1,1,1,1,1,1,1,1,1) | ||
assert value == "Error: >10 Values" |