-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion2.py
More file actions
29 lines (22 loc) · 724 Bytes
/
Copy pathquestion2.py
File metadata and controls
29 lines (22 loc) · 724 Bytes
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
#create an account class with 2 attributes - balance and account no.
#make methods for debit, credit and printing the balance
class Account():
def __init__(self,bal,acc):
self.balance = bal
self.account_no = acc
print("total balance is", self.get_balance())
#debit method
def debit(self,amount):
self.balance -= amount
print("Rs. ", amount, "was debited")
print("total balance is", self.get_balance())
#credit method
def credit(self,amount):
self.balance += amount
print("Rs. ", amount, "was credited")
print("total balance is", self.get_balance())
def get_balance(self):
return self.balance
acc1 = Account(10000, 11)
print(acc1.balance)
print(acc1.account_no)