Volume Area of a Cylinder || Classes || Python
In this we are going to see a basic program to calculate volume and area using classes in Python Programming Language.



class calc:
    def __init__(self):
        self.length = 0
        self.width = 0
        self.height = 0
 
    def data(self, l, w, h):
        self.length = l
        self.width = w
        self.height = h
 
    def Area(self):
        return 2 * (self.length + self.width + self.height)
 
    def Volume(self):
        return self.length * self.width * self.height
 
 
print("Enter the Length, Width and Height: \n", end='')
l, w, h = map(int, input().split())
calc1 = calc()
calc1.data(l, w, h)
print("Area = ", end='')
print(calc1.Area(), end='')
print(" sq units", end='')
print("\n", end='')
print("Volume = ", end='')
print(calc1.Volume(), end='')
print(" cubic units", end='')
print("\n", end='')
 
#Coded by SAAHIL


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post