Classes in Python
Define a class BOX in Python with following specifications
Instance Attributes
- BoxID # Numeric value with a default value 101
- Side # Numeric value with a default value 10
- Area # Numeric value with a default value 0
Methods:
- ExecArea() # Method to calculate Area as
# Side * Side
- NewBox() # Method to allow user to enter values of
# BoxID and Side. It should also
# Call ExecArea Method
- ViewBox() # Method to display all the Attributes
class BOX:
def __init__(self):
self.BoxID=101
self.Side=10
self.Area=0
def ExecArea(self):
self.Area=self.Side*self.Side
def NewBox(self):
self.BoxID=input('Enter BoxID')
self.Side=input('Enter side')
self.ExecArea()
def ViewBox(self):
print self.BoxID
print self.Side
print self.Area
Sponsor Area
What is the significance of super() method? Give an example of the same.
How do we implement abstract method in python? Give an example for the same.
Sponsor Area
Sponsor Area