CSE 1010 Lecture 12: 11/3/16 OOP2: Modeling a Bank Account

49 views3 pages
jadetortoise401 and 55 others unlocked
CSE 1010 Full Course Notes
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.

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