CSC148H1 Study Guide - Midterm Guide: Docstring, Init, Multiple Choice

82 views5 pages
25 Oct 2018
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

Implement a class that models a bank account. This account will know how to deposit money, withdraw money, and report the current balance in the account. Your class implementation need include only the following (the only parts we will grade): a declaration of class name, and a class docstring. an init method that sets up the account with an initial balance. a method to make a withdrawal, charging a overdraft and refusing the withdrawal if there are not enough funds. a method to report the current balance. All methods must have proper docstrings, except no examples are required. class bankaccount: Models a monthly bank account def __init__(self, balance=0): @rtype: none self. _balance = balance self. _intrate = 0. 0125 def make_deposit(self, deposit_amt): @rtype: none self. _balance += deposit_amt def make_withdrawal(self, withdraw_amt): @rtype: none if self. _balance < withdraw_amt: self. _balance -= 10 raise valueerror("not enough funds") else: self. _balance -= withdraw_amt. Implement a class that models a quiz question.