Link
input = open('input.txt', 'r')
output = open('output.txt', 'w')
L = list(map(str, input.read().split('\n')))
Accounts = dict()
for i in L:
if i != '':
st = list(i.split( ))
if st[0] == 'DEPOSIT':
Accounts[st[1]] = Accounts.get(st[1], 0) + int(st[2])
elif st[0] == 'INCOME':
for j in Accounts:
if Accounts[j] > 0:
Accounts[j] = int(Accounts[j] * ((100 + int(st[1])) / 100) // 1)
elif st[0] == 'BALANCE':
if st[1] in Accounts:
output.write(str(int(Accounts[st[1]])) + '\n')
else:
output.write('ERROR\n')
elif st[0] == 'TRANSFER':
Accounts[st[1]] = Accounts.get(st[1], 0) - int(st[3])
Accounts[st[2]] = Accounts.get(st[2], 0) + int(st[3])
elif st[0] == 'WITHDRAW':
Accounts[st[1]] = Accounts.get(st[1], 0) - int(st[2])
input.close()
output.close()
input = open('input.txt', 'r')
output = open('output.txt', 'w')
L = list(map(str, input.read().split('\n')))
Accounts = dict()
for i in L:
if i != '':
st = list(i.split( ))
if st[0] == 'DEPOSIT':
Accounts[st[1]] = Accounts.get(st[1], 0) + int(st[2])
elif st[0] == 'INCOME':
for j in Accounts:
if Accounts[j] > 0:
Accounts[j] = int(Accounts[j] * ((100 + int(st[1])) / 100) // 1)
elif st[0] == 'BALANCE':
if st[1] in Accounts:
output.write(str(int(Accounts[st[1]])) + '\n')
else:
output.write('ERROR\n')
elif st[0] == 'TRANSFER':
Accounts[st[1]] = Accounts.get(st[1], 0) - int(st[3])
Accounts[st[2]] = Accounts.get(st[2], 0) + int(st[3])
elif st[0] == 'WITHDRAW':
Accounts[st[1]] = Accounts.get(st[1], 0) - int(st[2])
input.close()
output.close()
Комментариев нет:
Отправить комментарий