-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtask10_5.py
41 lines (31 loc) · 969 Bytes
/
task10_5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def deposit(name, amount):
bank[name] = bank.get(name, 0) + int(amount)
def withdraw(name, amount):
bank[name] = bank.get(name, 0) - int(amount)
def balance(name):
log.append(bank[name] if name in bank else 'ERROR')
def income(percent):
for i, j in bank.items():
if j > 0:
bank[i] = int(j * ((int(percent) / 100) + 1))
def transfer(name1, name2, amount):
bank[name1] = bank.get(name1, 0) - int(amount)
bank[name2] = bank.get(name2, 0) + int(amount)
bank = dict()
log = []
for _ in range(int(input())):
line = input().split()
if 'BALANCE' in line:
balance(line[1])
elif 'DEPOSIT' in line:
deposit(line[1], line[2])
elif 'WITHDRAW' in line:
withdraw(line[1], line[2])
elif 'INCOME' in line:
income(line[1])
elif 'TRANSFER' in line:
transfer(*line[1:])
else:
withdraw(line[1], line[3])
deposit(line[2], line[3])
print(*log, sep='\n')