Rebuilt_Python_IEEE_Document
Rebuilt_Python_IEEE_Document
Part - A Question
8. Design a Bank Account System with Multiple Account Types
Scenario:
You are developing a banking application. The system needs to support multiple types of
bank accounts, such as savings and checking accounts. Both account types share common
functionalities like deposit and withdrawal, but they may have different rules or restrictions
for withdrawals.
Question:
Design an object-oriented system to model the bank accounts:
• Create a parent class BankAccount that includes attributes like account holder’s name,
balance, and account number, as well as methods like deposit() and withdraw().
• Create subclasses SavingsAccount and CheckingAccount that inherit from BankAccount.
The SavingsAccount should have a restriction on the number of withdrawals per month,
while the CheckingAccount should have a lower interest rate.
• Override the withdraw() method in the subclasses to implement specific withdrawal rules.
• Implement a method get_balance() to return the account balance and display it.
• Provide a method to calculate interest in SavingsAccount.
Python Code:
class BankAccount:
def __init__(self, name, balance, account_number):
self.name = name
self.balance = balance
self.account_number = account_number
Part - B Question
3. a) What is class and object? (2M)
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allows methods to do different things based on the object calling them.
class Student:
school = "VFSTR" # Class attribute
# Creating object
s1 = Student("Ram", 101)
print(s1.name)
print(Student.school)