Python Programming - Objects - Discussion

Discussion Forum : Objects - General Questions (Q.No. 8)
8.
Consider the following Python code:
class BankAccount:
    def __init__(self, balance):
        self.balance = balance

    def withdraw(self, amount):
        if amount <= self.balance:
            self.balance -= amount
            return True
        else:
            return False
What does the withdraw method return if the withdrawal is successful?
True
False
The updated balance
None
Answer: Option
Explanation:
The withdraw method returns True if the withdrawal is successful, indicating that the amount was deducted from the balance.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.