CSE 1010 Lecture 12: 11/3/16 OOP2: Modeling a Bank Account
jadetortoise401 and 55 others unlocked
84
CSE 1010 Full Course Notes
Verified Note
84 documents
Document Summary
You will use functions, lists, etc in your model. You need to decide what features you want to model. Def create_acct(number, name, balance): acct = ___ return acct. Acct = { num": number, name": name, bal": balance} Probably the better option because the fields are named, you don"t need to remember number is at [0], name is at [1], balance is at [2], etc. Def create_acct(number, name, balance): acct = { num": number, name": name, bal": balance} return acct. # this doesn"t display anything because it is an assignment statement. Def deposit(acct, amount): bal = acct[ bal"] newbal = bal + amount acct[ bal"] = newbal. #it doesn"t display anything because there was no print statement added in the function, and there was no return statement, it only modified the state of the account. Def withdraw(acct, amount): bal = acct[ bal"] newbal = bal - amount acct[ bal"] = newbal.