Question

Consider the following Python code: from abc import ABC, abstractmethod class Shape(AB

  • C :     @abstractmethod     def area(self):         pass class Circle(Shape):     def __init__(self, radius):         self.radius = radius     def area(self):         return 3.14 * self.radius * self.radius # What will be the output of the following? # s = Shape() # print(s.area()) What will happen if you try to execute the commented-out lines `s = Shape()` and `print(s.area())`?
A It will print "None".
B It will print "0.0".
C It will raise a `TypeError` because `Shape` is an abstract class and cannot be instantiated.
D It will raise an `AttributeError` because `area` is not implemented in `Shape`.
E It will execute successfully and print an undefined value.
Practice Next

Hey! Ask a query