Feb-13-2019, 01:51 AM
(Feb-10-2019, 09:39 PM)snippsat Wrote: As your radius is a default argument,then so canpie
be. It can also be be a class attribute withself.pie
as @buran suggests.class Circle: def __init__(self, radius=1, pie=3.14): self.radius = radius self.pie = pie self.area = self.pie * self.radius * self.radius def circum(self): return(2 * self.pie * self.radUse:>>> mycircle = Circle() >>> mycircle.circum() 6.28 >>> # Can change radius,pie is the same as it always has been >>> mycircle = Circle(2) >>> mycircle.circum() 12.56Also look at PEP-8,for small changes that i made.
Great ... :)
Thanks a lot Bros...it feels awesome getting so much help..
Bundle of thanks both of you @buran, @snippsat