Python_OOP_Cylinder_Tutorial
Python_OOP_Cylinder_Tutorial
A class is a blueprint for creating objects. It defines properties (attributes) and behaviors (methods).
class Example:
def __init__(self, value):
self.value = value
def show_value(self):
print('Value:', self.value)
obj = Example(10)
obj.show_value() # Output: Value: 10
class Cylinder:
def __init__(self, radius, height):
self.radius = radius
self.height = height
def calculate_surface_area(self):
return 2 * math.pi * self.radius * (self.radius + self.height)
def calculate_volume(self):
return math.pi * (self.radius ** 2) * self.height
def calculate_lateral_surface(self):
return 2 * math.pi * self.radius * self.height