[go: up one dir, main page]

0% found this document useful (0 votes)
23 views1 page

Interview Que

Uploaded by

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

Interview Que

Uploaded by

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

Create a Python class called BankAccount that represents a simple bank account.

The
class should have the following attributes and methods:

Attributes:

account_number: A unique identifier for the bank account.


balance: The current balance of the bank account.
Methods:

__init__(self, account_number): Initializes a new bank account with the given


account_number and sets the initial balance to 0.
deposit(self, amount): Adds the specified amount to the account balance.
withdraw(self, amount): Subtracts the specified amount from the account balance,
but only if there are sufficient funds. If there are not enough funds, print a
message indicating insufficient balance.
get_balance(self): Returns the current balance of the account.
Write the BankAccount class implementation in Python, and then create an instance
of the class to demonstrate its usage by depositing and withdrawing funds.
Extend the BankAccount class to include the following additional features:

Allow the account holder to set an overdraft limit.


Implement a method to transfer funds between two bank accounts.
Ensure that all transactions (deposits, withdrawals, transfers) are recorded with
timestamps.
Abhishek Rana
4:31 PM
Your implementation should include the necessary modifications to the class
structure, attributes, and methods to accommodate these new requirements.
Additionally, provide a demonstration of the usage of these new features by
creating instances of the BankAccount class and performing various transactions.

You might also like