lr5

parent c476f98e
......@@ -19,31 +19,31 @@ def calculate(*args, **kwargs):
output_type = kwargs['output_type']
print(precision)
if args[len(args) - 1] == '+':
result_sum = sum(args[0:len(args) - 1])
if args[args[-1]] == '+':
result_sum = sum(args[0:args[-1]])
if type(result_sum) is not output_type:
result_sum = output_type(result_sum)
return result_sum
if args[len(args) - 1] == '-':
if args[args[-1]] == '-':
result_diff=0
for n in args[0:len(args) - 1]:
for n in args[0:args[-1]]:
result_diff -= n
if type(result_diff) is not output_type:
result_sum = output_type(result_diff)
return result_diff
if args[len(args) - 1] == '*':
if args[args[-1]] == '*':
result_mult = 1
for n in args[0:len(args) - 1]:
for n in args[0:args[-1]]:
result_mult *= n
if type(result_mult) is not output_type:
result_mult = output_type(result_mult)
return round(result_mult, precision)
if args[len(args) - 1] == '/':
if args[args[-1]] == '/':
result_division = args[0]
for n in args[1:len(args) - 1]:
for n in args[1:args[-1]]:
result_division /= n
if type(result_division) is not output_type:
result_division = output_type(result_division)
......
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