lr6

parent 75a4d38c
......@@ -21,15 +21,15 @@ def print_results(*args, action=None, result=None):
def actionPrint(operands, action):
lst=[]
for i in range(operands[0],operands[-1]):
lst.append(f" {i} {action} ")
lst.append(f" {operands[-1]} ")
lst.append(f"{i} {action}")
lst.append(f"{operands[-1]}")
return lst
arg_list=str((argsPrint(operands)))
action_list=str(actionPrint(operands, action))
st = f"| {arg_list} | {action_list} = {result} |"
print('-' * len(st))
arg_list=(" ".join((argsPrint(operands))))
action_list=(" ".join(actionPrint(operands, action)))
st = f"{arg_list} {action_list} = {result} |"
print('-' * len(st))
print(st)
print('-' * len(st))
......
......@@ -51,12 +51,6 @@ def calculate(*args, **kwargs):
return round(result_division, precision)
print(calculate(*list(range(1, 10)), "+", **PARAMS), '\n') # 1 + 2 + 3 + .. + 9
print(calculate(*list(range(1, 10)), "-", **PARAMS), '\n')
print(calculate(*list(range(1, 5)), "/", **PARAMS), '\n')
print(calculate(*[1.0001, 2.2345], "*", **PARAMS), '\n') # 2.23472345
def test_packed_calc_sum():
inp1, action = [1, 2, 3, 4, 5, 6, 7, 8, 9], "+"
assert calculate(*inp1, action,
......@@ -66,8 +60,8 @@ def test_packed_calc_sum():
if __name__ == "__main__":
# print(calculate(*list(range(1, 10)), "+", **PARAMS), '\n') # 1 + 2 + 3 + .. + 9
# print(calculate(*list(range(1, 10)), "-", **PARAMS), '\n')
# print(calculate(*list(range(1, 5)), "/", **PARAMS), '\n')
# print(calculate(*[1.0001, 2.2345], "*", **PARAMS), '\n') # 2.23472345
assert calculate(*list(range(1, 10)), "+", **PARAMS) == 45.0 # 1 + 2 + 3 + .. + 9
assert calculate(*list(range(1, 10)), "-", **PARAMS) == -45
assert calculate(*list(range(1, 5)), "/", **PARAMS) == 0.04167
assert calculate(*[1.0001, 2.2345], "*", **PARAMS)== 2.23472
print_results(*list(range(1, 10)), action = "+", result=calculate(*list(range(1, 10)), "+", **PARAMS))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment