Page 1 of 1

Simple program for class

Posted: Sat Sep 25, 2010 3:28 pm
by Isaac
This is meant to be used after being imported into the Python terminal. After its loaded each account is its own instance which returns a usable value, like Cash.bal(). Examples:>>> AcPay.add(Cash.bal()-513.30) >>> Cash.add(50000)
To keep track of all the accounts I type dir()
It's simple but I'm a beginner.

Code: Select all

class account:
	def __init__(self):
		self.all = []
	def add(self, dollarval):
		self.all.append(dollarval)
	def show(self):
		a=1
		for transactions in self.all:
			print a,\")  $\", transactions
			a+=1
	def bal(self):
		a=0
		for transactions in self.all:
			a=transactions+a	
		return a
	def u(self):
		del self.all[-1]
Note: python is a hobby of mine, but I use it for school as a calculator.