Elegant Code With Python by A K Karthikeyan

Elegant Code With Python by A K Karthikeyan

Author:A K, Karthikeyan [A K, Karthikeyan]
Language: eng
Format: epub, pdf
Publisher: Karthikeyan a K
Published: 2021-10-28T16:00:00+00:00


24. Avoid Chain Equal To

Hmmm

a = b = c = 5

Elegant

a = 5

b = 5

c = 5

25. Inherit Classes And Reuse Code If Possible

Hmmm

class Rectangle ():

def __init__(self, length, breadth):

self.length = length

self.breadth = breadth

def area(self):

return self.length * self.breadth

class Square ():

def __init__(self, side_length):

self.side_length = side_length

def area(self):

return self.side_length * self.side_length

square = Square(5)

print (square.area())

Elegant

class Rectangle ():

def __init__(self, length, breadth):

self.length = length

self.breadth = breadth



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.