Question
What will be the output of the following code snippet
demonstrating abstraction in Python? from abc import ABC, abstractmethod class Shape(ABC):   @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 circle = Circle(5) print(circle.area())Solution
In the given code snippet, an abstract base class Shape is defined with an abstract method area. The Circle class inherits from Shape and implements the area method, which calculates the area of a circle using the formula πr2\pi r^2πr2. When the Circle instance with a radius of 5 is created, calling circle.area() computes the area as 3.14×5×5=78.53.14 \times 5 \times 5 = 78.53.14×5×5=78.5. Therefore, the output is 78.5. Why Other Options Are Wrong: A) 3.14: This option is incorrect because it only represents the value of π, not the computed area. B) 31.4: This option is incorrect as it suggests a miscalculation of the area, possibly interpreting it as π multiplied by the radius. D) 25: This option is incorrect because it reflects the square of the radius (5), not the area. E) TypeError: This option is incorrect because there is no type error; the code correctly implements abstraction and executes without issues.
What is the need to balance chemical equations?Â
A shopkeeper sells glasses at the rate of Rs. 40 each and earns a commission of 18%. He also sells vases at the rate of Rs. 80 each and earns a commiss...
Consider the following statements related to the World War II:
1. Germany attacked the US naval base at Pearl Harbour.
2. Winston Church...
Assertion (A): Unity of command cannot always be strictly applied in practice.
Reason (R): Workers should report to different supervisors for ...
ATL Sarthi mission is launched by which of the following institutions?
Assertion (A): Macro-economic deals with the study of aggregates and averages.
Reason (R): Central problem of macro-economics is the determina...
Who is entrusted with the authority to enforce the Fundamental Rights as per the Constitution?
1.   The President
2.   The Supreme...
What does API stand for in computer programming?
Which state commenced its first survey of migrants?
Which shortcut key is used for previewing the page before printing?Â