I'm a new person to coding and while creating this program i had a thought
Q- make a program where you can see the amount of money the people who have deposited money in the bank will get after 1 year with 12% intrest on it and calculate the total intrest paid in 1 year
Ans-
balance= [12000,10000,33000,55000]
total= 0
for i in balance :
intst= i*12*1/100
total= total intst
print("intres of",i,"=",intst)
print("total intrest paid by the bank in 1 year =",total)
I wondered if i could specify names of the people who had deposited the money in it and when it prints it would show up like xxxx deposited 12000 = 1440.0
I'm sorry if this sounds too complicated or stupid I'm just genuinely curious to see if it's possible
I tried using dictionary but horribly failed lmao
CodePudding user response:
The dictionary can be used in the format {"Name" : 1000} # 1000 being the deposit amount
interest_rate = 0.12
balances = {
"John": 12000,
"Joseph": 10000,
"Joline": 33000,
"Jose": 55000
}
interests = []
for name in balances:
deposit = balances[name]
interest = deposit * interest_rate
print(f"{name} deposited {deposit}, after one year, the interest was {interest}")
Output:
John deposited 12000, after one year, the interest was 1440.0
Joseph deposited 10000, after one year, the interest was 1200.0
Joline deposited 33000, after one year, the interest was 3960.0
Jose deposited 55000, after one year, the interest was 6600.0