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