0% found this document useful (0 votes)
6 views3 pages

Rebuilt_Python_IEEE_Document

The document outlines a Python exam focused on designing a bank account system using object-oriented principles, including a parent class and subclasses for different account types. It also includes questions about fundamental programming concepts such as classes, objects, inheritance, and polymorphism, along with example code. The exam assesses both practical coding skills and theoretical understanding of object-oriented programming concepts.

Uploaded by

prorider2937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Rebuilt_Python_IEEE_Document

The document outlines a Python exam focused on designing a bank account system using object-oriented principles, including a parent class and subclasses for different account types. It also includes questions about fundamental programming concepts such as classes, objects, inheritance, and polymorphism, along with example code. The exam assesses both practical coding skills and theoretical understanding of object-oriented programming concepts.

Uploaded by

prorider2937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

IEEE Format Python Exam 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

def deposit(self, amount):


self.balance += amount
print(f"{amount} deposited. New balance: {self.balance}")

def withdraw(self, amount):


if amount <= self.balance:
self.balance -= amount
print(f"{amount} withdrawn. New balance: {self.balance}")
else:
print("Insufficient balance!")
Output Screenshot:

Part - B Question
3. a) What is class and object? (2M)

A class is a blueprint for creating objects in programming. An object is an instance of a class


containing data and behavior defined by the class.

b) Difference between inheritance and polymorphism.

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.

c) Creating a class and object with class and instance attributes.

class Student:
school = "VFSTR" # Class attribute

def __init__(self, name, roll_no):


self.name = name # Instance attribute
self.roll_no = roll_no

# Creating object
s1 = Student("Ram", 101)
print(s1.name)
print(Student.school)

You might also like