class Shape:
def __init__(self, x, y, name, age):
self.x = x
self.y = y
self.name = name
self.age = age
description = "This shape has not been described yet"
author = "Nobody has claimed to make this shape yet"
def area(self):
return self.x * self.y
def perimeter(self):
return 2 * self.x + 2 * self.y
def describe(self,text):
self.description = text
def authorName(self,text):
self.author = text
def scaleSize(self,scale):
self.x = self.x * scale
self.y = self.y * scale
How do i print the attributes in authorName , describe and scaleSize as so far i have only been able achieve this result.
objectname = Shape(8,10, 'Peter Adom', '55')
print(objectname.name)
print(objectname.area())
print(objectname.perimeter())
describeis not a "getter" it is a "setter". It acts to set the author name for someShapeobject. You would need some functiondef printAuthor(self): print(self.author)then you could callobjectname.printAuthor()print objectname.author.