I wrote a Python program to calculate the cost of a land. Why can't I just write "Land.cost() instead of "Land(0,0,0).cost()
" inside print function?
class Land:
def __init__(self, length, width, unitcost):
self.length = input ('length :')
self.breadth = input('width :')
self.unitcost = input('unitcost :')
def cost(self):
return int(self.length) * int(self.breadth) * int(self.unitcost)
print ( 'Cost of Land is: $' + str( Land(0,0,0).cost() ) )