Simple program for class

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7649
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

Simple program for class

Post 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.
Post Reply