Professional Documents
Culture Documents
Practical5 22bce506 PSC
Practical5 22bce506 PSC
Practical No: 5
Practical 5 a. Define a class Bank that keeps track of bank customers. The class should
contain the following data member: The class should support the following methods: (a) init
for initializing the data members. (b) deposit for depositing money in the members. (c)
withdrawal for withdrawing money from the account (d) findInterest that determines the
interest on the basis of amount in the account
def __init__(self,name,accountnum,t_ype,amount):
self.name = input("Enter your Name : ")
self.accountnum = int(input("Enter your Accountnum : "))
self.type = input("Enter your account type : ")
self.amount = int(input("Enter the amount : "))
def deposit(self):
amount = int(input("Enter deposit amount : "))
self.amount += amount
print("The amount is : ",self.amount)
def withdrawal(self):
amount = int(input("Enter withdrawal amount : "))
self.amount -= amount
print("Withdrawal amount is : ",self.amount)
def findinterest(self):
if self.amount >= 5000000:
self.interest = self.amount * 0.08
self.amount += self.interest
elif self.amount >= 300000 and self.amount < 500000:
self.interest = self.amount * 0.07
self.amount += self.interest
elif self.amount >= 100000 and self.amount < 300000:
self.interest = self.amount * 0.05
self.amount += self.interest
elif self.amount < 100000:
self.interest = self.amount * 0.03
self.amount += self.interest
a = b = c = d = 0
p = Bank(a,b,c,d)
choice = 0
while True:
x = int(input("""Enter your choice \n 1. Deposit \n 2. Withdrawal \n 3. Findint
if x == 1:
p.deposit()
if x == 2:
p.withdrawal()
if x == 3:
p.findinterest()
localhost:8888/nbconvert/html/Downloads/Practical5_22bce519_psc.ipynb?download=false 1/3
4/8/23, 3:34 PM Practical5_22bce519_psc
if x == 4:
break
Practical 5 b. Define a base class Person, having attributes name, birthdate and city. Define
the class Student that derives from Person class which is having attributes like rollno, branch,
totalMarks and year as data member. The class should contain the instance method init and
the percentage with pass statement. Define two classes Grad and PostGrad which inherit
from the base class Student. Both the classes should define their init method which asks
user to enter totalMarks value and should override the method percentage of the
superclass. Note that totalMarks obtained are out of 600 and 400 for Grad and PostGrad
classes respectively
class student(person):
def __init__(self,rollno,branch,year,totalmark = 0):
super().__init__(name,birthday,branch)
print(self.city)
self.rollno = rollno
self.branch = branch
self.year = year
def percentage(self):
localhost:8888/nbconvert/html/Downloads/Practical5_22bce519_psc.ipynb?download=false 2/3
4/8/23, 3:34 PM Practical5_22bce519_psc
pass
class grade(student):
def __init__(self,tm):
self.totalmark = tm
def percentage(self):
per1 = self.totalmark / 6
print("grade of ",per1)
class postgrade(student):
def __init__(self,tm):
self.totalmark = tm
def percentage(self):
per2 = self.totalmark / 4
print("grade of ",per2)
pp = person(name,birthday,city)
ss = student(rollno,branch,year)
localhost:8888/nbconvert/html/Downloads/Practical5_22bce519_psc.ipynb?download=false 3/3