"""
There are no interfaces in Python. We will use normal classes instead
"""
class Rectangle:
def compute(self, x, y):
return x*y
class Circle:
pi = 3.14
def compute(self, x, y):
return self.pi*x*x
rect = Rectangle()
cir = Circle()
print "Area of rectangle: ", rect.compute(10, 20)
print "Area of circle: ", cir.compute(10, 0)
class Student(object):
rollNumber = 0
def getNumber(self, n):
self.rollNumber = n
def putNumber(self):
print "Roll No.: ", self.rollNumber
class Test(Student, object):
part1 = 0.0
part2 = 0.0
def getMarks(self, m1, m2):
self.part1 = m1
self.part2 = m2
def putMarks(self):
print "Marks Obtained"
print "Part 1 = ", self.part1
print "Part 2 = ", self.part2
class Results(Test):
sportWt = 6.0
def putWt(self):
print "Sports Wt: ", self.sportWt
def display(self):
total = self.part1 + self.part2 + self.sportWt
self.putNumber()
self.putMarks()
self.putWt()
print "Total Score: ", total
student1 = Results()
student1.getNumber(1234)
student1.getMarks(27.5, 33.0)
student1.display()