2020-06-01 13:20:55 +00:00
|
|
|
from sys import argv
|
|
|
|
|
|
|
|
script, file_name = argv
|
|
|
|
|
|
|
|
|
|
|
|
def input_and_calculate_one_line():
|
|
|
|
txt_result = ''
|
|
|
|
number = input("> ")
|
|
|
|
if number == 'q':
|
|
|
|
txt_result = ''
|
|
|
|
return txt_result
|
|
|
|
|
|
|
|
sp_number = number.split(' ')
|
|
|
|
for i in range(len(sp_number) - 1):
|
2020-06-01 14:43:40 +00:00
|
|
|
txt_result = txt_result + sp_number[i] + ' + '
|
2020-06-01 13:20:55 +00:00
|
|
|
|
|
|
|
sp_number = list(map(int, sp_number))
|
|
|
|
result = sum(sp_number)
|
2020-06-01 14:43:40 +00:00
|
|
|
txt_result = txt_result + str(sp_number[-1]) + ' = ' + str(result) + '\n'
|
2020-06-01 13:20:55 +00:00
|
|
|
return txt_result
|
|
|
|
|
|
|
|
|
|
|
|
def editor():
|
|
|
|
txt = open(file_name, 'w')
|
|
|
|
while True:
|
|
|
|
output = input_and_calculate_one_line()
|
|
|
|
if output == '':
|
|
|
|
txt.close()
|
|
|
|
exit(0)
|
|
|
|
else:
|
|
|
|
print(output)
|
|
|
|
txt.write(output)
|
|
|
|
|
|
|
|
|
|
|
|
editor()
|