CSE 1010 Lecture 21: BANK ACCOUNTS WITH ALL-NEW EXCEPTIONS
WEEK 13 - LECTURE 21 - BANK ACCOUNTS WITH ALL-NEW EXCEPTIONS
BANK ACCOUNTS
● Recall the bank account class:
○ The Python convention is to name instance variables with underscores.
○ It hides them, and it means "Only methods in this class should use these
variables."
● New deposit function different from the previous one
○ Now we return the new balance from deposit.
● Withdraw function
○ Return the new balance from withdraw.
Exceptions
● But what if the account doesn't have enough money?
○ A function should return a correct value or it should not return at all.
● New withdraw function
○ This function is guaranteed to return the new balance.
jadetortoise401 and 55 others unlocked
84
CSE 1010 Full Course Notes
Verified Note
84 documents