Python Programming - Objects - Discussion
Discussion Forum : Objects - General Questions (Q.No. 6)
6.
Consider the following Python code:
class Circle:
def __init__(self, radius):
self.radius = radius
def calculate_area(self):
return 3.14 * self.radius * self.radius
How would you create an instance of the Circle class with a radius of 5?
Answer: Option
Explanation:
The correct way to create an instance of the Circle class with a radius of 5 is to use the constructor and pass the value as a named argument.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers