8. Write a python program to find the whether the given input is palindrome or not (for both
string and integer) using the concept of polymorphism and inheritance.
# find palendrom or not for both integer and string using polymorphism and inheritance
class PaliStr:
def __init__(self):
self.isPali=False
def cheakPali(self,myStr):
if myStr==myStr[::-1] :
self.isPali=True
else:
self.isPali=False
return self.isPali
class PaliInt(PaliStr):
def __init__(self):
self.isPali=False
def cheakPali(self,val):
temp=val
rev=0
while temp!=0:
dig=temp%10
rev=(rev*10)+dig
temp=temp//10
if val==rev:
self.isPali=True
else:
self.isPali=False
return self.isPali
st=input("Enter a string: ")
stobj=PaliStr()
if stobj.cheakPali(st):
print("Given string is palindrom")
else:
print("not palindrom")
val=int(input("Enter a string: "))
intobj=PaliInt()
if intobj.cheakPali(val):
print("Given integer is a palindrome")
else:
print("Not palindrome")
