You are on page 1of 3

4/8/23, 3:34 PM Practical5_22bce519_psc

Roll No: 22BCE06

Name: Jenish Gajera

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

In [1]: class Bank:

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

print("Your interest is : ",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

Enter your Name : jenish


Enter your Accountnum : 0808
Enter your account type : saving
Enter the amount : 5000
Enter your choice
1. Deposit
2. Withdrawal
3. Findinterest
4.exit
1
Enter deposit amount : 300
The amount is : 5300
Enter your choice
1. Deposit
2. Withdrawal
3. Findinterest
4.exit
3
Your interest is : 159.0
Enter your choice
1. Deposit
2. Withdrawal
3. Findinterest
4.exit
2
Enter withdrawal amount : 1000
Withdrawal amount is : 4459.0
Enter your choice
1. Deposit
2. Withdrawal
3. Findinterest
4.exit
4

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

In [2]: class person:


def __init__(self,name,birthday,city):
self.name = name
self.birthday = birthday
self.city = city

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)

name = input("Enter the name : ")


birthday = int(input("Enter the birthday : "))
city = input("Enter the city : ")
rollno = int(input("Enter the rollno : "))
branch = input("Enter the branch : ")
year = input("Enter the year : ")

pp = person(name,birthday,city)
ss = student(rollno,branch,year)

tm = eval(input("Enter the marks obtain by 600 : "))


gg = grade(tm)
gg.percentage()

tm = eval(input("Enter the marks obtain by 400 : "))


pp = postgrade(tm)
pp.percentage()

Enter the name : Jenish


Enter the birthday : 080808
Enter the city : ankle
Enter the rollno : 506
Enter the branch : cse
Enter the year : 2023
cse
Enter the marks obtain by 600 : 333
grade of 55.5
Enter the marks obtain by 400 : 333
grade of 83.25

localhost:8888/nbconvert/html/Downloads/Practical5_22bce519_psc.ipynb?download=false 3/3

You might also like