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.
- Read each sentence to find out whether there is any grammatical error in it. The error, if any, will be in one part of the sentence. Mark the part with the...
We have entered into an agreement to buy 100 per cent of the equity shares of England-headquartered company in an all cash deal ofRs. 250 crore.Â
Read the sentence to find out whether there is any grammatical or idiomatic error in it. The error, if any, will be in one part of the sentence. The le...
Building a stable balance of power (A)/in the Indo-Pacific has become (B)/more crucial than ever for internationally security (C).
The GST Council which will now oversees the new tax architecture must focus initially on stabilising the system and then improving on the current design...
Her gratuity and provident fund were settled in 2005. Since , her request for pension was not considered.
...If any Governor believed that he had (1)/many say in the matter of fixing a date for the Speaker’s election, (2)/it is both contrary to the constitut...
While discretion and quiet negotiations are useful, (A) / such divergence in public statements also fuels (B) / speculation that something deeper (C) /...
Located 140 km away from Srinagar, Drass valley in Kargil District is often described as the “Gateway to Ladakh.”Â
Parts of the following sentence are given as options. Identify the segment that contains a grammatical error.
Ramprasad has not been able to co...