Created
September 14, 2019 14:00
-
-
Save vubon/e87087176183a9b4092fb2cb7ea4646c to your computer and use it in GitHub Desktop.
Python Property function part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account: | |
""" A basic class that store bank account information """ | |
def __init__(self, bank_account: str, balance: float): | |
self.bank_account = bank_account | |
self.balance = balance | |
self.account_information = dict(bank_account=self.bank_account, balance=self.balance) | |
def __str__(self): | |
return f"Bank Account: {self.bank_account} - balance: {self.balance}" | |
account = Account("0004-0067894712", 1000.50) | |
print(f"account number: {account.bank_account}") | |
print(f"Current balance: {account.balance}") | |
print(f"Account information: {account.account_information}") | |
# Output should look like this | |
# account number: 0004-0067894712 | |
# Current balance: 1000.5 | |
# Account information: {'bank_account': '0004-0067894712', 'balance': 1000.5} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment