Python Programming - Objects - Discussion
Discussion Forum : Objects - General Questions (Q.No. 13)
13.
Consider the following Python code:
class BankAccount:
def __init__(self, balance):
self.balance = balance
def deposit(self, amount):
self.balance += amount
return self.balance
If you create an instance of the `BankAccount` class called my_account
with an initial balance of 100 and then call my_account.deposit(50)
, what will be the updated balance?
Answer: Option
Explanation:
The
deposit
method adds the specified amount to the balance. In this case, it would be 100 + 50 = 150.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers