+ 1

Plz tell the problem , actually i want to calculalate monthly interest on bank balance

https://code.sololearn.com/clbGMG6ZN5Bs/?ref=app

20th Dec 2019, 1:09 PM
Surya Prakash
Surya Prakash - avatar
2 odpowiedzi
+ 2
You have some class variables not declared(like self.type, self.interest). I've made some changes in the code, now there's no error. If you don't want it to be displayed on the screen, you can just delete that row. Hope it helps? from datetime import date class account: def __init__(self,number,type,interest): self.number = number self.type = type self.interest = interest def account_type(self): if str(self.number).startswith("1"): self.type = "current" elif str(self.number).startswith("2"): self.type = "savings" def interest_rate(self): if self.type == "current": self.interest = 0 else: self.interest = 5 return self.interest def interest_return(self): self.interest_rate () balance = 1000 cdate = date.today() bdate = date(cdate.year, 1, 1) interest_return_var = balance*abs((cdate - bdate).days/365)*self.interest /100 print(interest_return_var) acc = account (1001, "",0) acc.interest_return ()
20th Dec 2019, 2:38 PM
molang
molang - avatar
0
Thanx to give me support, i think u forget self. In print anyway thnx https://code.sololearn.com/clbGMG6ZN5Bs/?ref=app
21st Dec 2019, 1:24 AM
Surya Prakash
Surya Prakash - avatar