Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created September 24, 2020 19:45
Show Gist options
  • Save mayankdawar/a2949fa68e4f5e75f36de6f0e2962653 to your computer and use it in GitHub Desktop.
Save mayankdawar/a2949fa68e4f5e75f36de6f0e2962653 to your computer and use it in GitHub Desktop.
Define a class called BankAccount that accepts the name you want associated with your bank account in a string, and an integer that represents the amount of money in the account. The constructor should initialize two instance variables from those inputs: name and amt. Add a string method so that when you print an instance of BankAccount, you see…
class BankAccount:
def __init__(self, name, amt):
self.name = name
self.amt = amt
def __str__(self):
return 'Your account, {}, has {} dollars.'.format(self.name, self.amt)
t1 = BankAccount('Bob',100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment