CSE 1010 Lecture 21: BANK ACCOUNTS WITH ALL-NEW EXCEPTIONS

18 views4 pages
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.
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in
jadetortoise401 and 55 others unlocked
CSE 1010 Full Course Notes
84
CSE 1010 Full Course Notes
Verified Note
84 documents

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents