Im just try to build a basic class so that I can learn some more about python.
So far I have the following :
class Bodymassindex:
count = 0
def __init__(self,name,weight,height):
self.name = name
self.weight = 14 * weight
self.height = 12 * height
notes = "no notes have been assigned yet"
bmitotal = 0
Bodymassindex.count += 1
def displayCount(self):
print "Total number of objects is %d" % Bodymassindex.count
def notesBmi(self,text):
self.notes = text
def calcBmi(self):
return ( self.weight * 703 ) / ( self.height ** 2 )
In terms of adding a note variable and viewing what is the correct way of doing so ?
Thanks,
Just access the attribute:
There is nothing wrong with direct access in Python. As others have noted, it’s likely you meant to make
notesandbmitotalinstance variables, which I have done here.