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())
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 target capacity for hydroelectric projects by 2031-32, as per the revised scheme?
Which of the following company has partnered with Jana Small Finance Bank to deploy card machines to further drive digitisation among merchants across t...
Who is attending the 60th Munich Security Conference in Germany from India?
Who has been appointed as the new India head by Morgan Stanley in replacement of Sanjay Shah?
How many of the World Heritage Sites in India, as of 2023, are classified as cultural sites?
The Aparajita Women and Child (West Bengal Criminal Laws Amendment) Bill, 2024 mandates that investigations into rape cases must be completed within how...
Evaluate the following statements concerning India's thermal coal imports in the first quarter of 2024 :
I . There was a 23 % year - on - ...
Who has been elected as the new president of the Fédération Internationale de l'Automobile (FIA)?
India is not the part of which of the following international Organisation?
The 'One State, One RRB' policy aims to: