Account

class account.Account(name)[source]

An account is one fund in a bank.

In reality, banks don’t keep everyone’s money separate, they just put all the money together and keep track of how much belongs to each account. Banks don’t even keep enough money around to pay out everyone’s accounts. They loan out your money to others for a profit and just keep enough for the amount they expect people to withdraw. In the past, there have been times when something scary happened and everybody wanted to take their money out at once and there wasn’t enough. This is called a “run on the bank.”

Args:

name: A string for the account name.

Example:

>>> from account import Account
>>> my_money = Account("Piggy bank")
Account Piggy bank            | Account opened.
>>> my_money.deposit(100)
Account Piggy bank            | Deposited 100. New balance is 100.
>>> my_money.withdraw(50)
Account Piggy bank            | Withdrew 50. New balance is 50.
>>> my_money.withdraw(200)
Account Piggy bank            | Can't withdraw 200. Insufficient balance.
deposit(amount)[source]

Deposits funds into the account, checking that amount is not negative.

Parameters

amount (float) – How much to deposit.

Returns

Whether the deposit succeeded.

Return type

bool

withdraw(amount)[source]

Withdraws funds from the account if possible.

Parameters

amount (float) – How much to withdraw.

Returns

Whether the withdrawal succeeded.

Return type

bool

check_balance()[source]

Reports the balance of the account

Parameters

account_name (str) – The account name.

Returns

The account balance.

report(activity)[source]

Prints out a report of activity.

Parameters

activity (str) – A description of what happened.