Answers for "abstarct class python"

0

abstarct class python

import abc
class Shape(metaclass=abc.ABCMeta):
   @abc.abstractmethod
   def area(self):
      pass
class Rectangle(Shape):
   def __init__(self, x,y):
      self.l = x
      self.b=y
   def area(self):
      return self.l*self.b
r = Rectangle(10,20)
print ('area: ',r.area())
Posted by: Guest on December-05-2020
0

abstarct class python

from abc import ABC

class MyABC(ABC):
    pass
Posted by: Guest on December-05-2020

Python Answers by Framework

Browse Popular Code Answers by Language