You are on page 1of 2

PRACTICAL NO: 14

# (1)
class Display:

def printmsg(self, x, y):

if isinstance(x, int):

print("Integer message =", x)

else:

print("Character message =", x)

disp = Display()

disp.printmsg(20, "abc")

disp.printmsg("abc", 20)

#(2)
class Area:

def print_area(self, l, b=None):

if b is not None:

print("Area of rectangle =", l * b)

else:

print("Area of square =", l * l)

area = Area()
area.print_area(11, 11)

area.print_area(13)

#(3)
class Degree:

def getDegree(self):

print("I got a degree")

class Undergraduate(Degree):

def getDegree(self):

print("I am an Undergraduate")

class Postgraduate(Degree):

def getDegree(self):

print("I am a postgraduate")

d = Degree()

u = Undergraduate()

p = Postgraduate()

d.getDegree()

u.getDegree()

p.getDegree()

You might also like