Professional Documents
Culture Documents
Program 9. User Defined Module - 1 Aim
Program 9. User Defined Module - 1 Aim
PROGRAM CODING
#NUMBER.PY
#palindrome without using strings
def palindrome(num):
''' A Number is said to be Palindrome if the original
and the reverse number are same'''
b=0
temp=num
while num>0:
a=num%10
b=b*10+a
num=num//10
if temp==b: return 1
else: return -1
def splnum(num):
'''A special number is a number equal to the sum
of the factorial of the individual digits of the number'''
import math
s,b,tem=0,0,num
while num>0:
a=num%10
s+=math.factorial(a)
num=num//10
if s== tem:
return 1
else:
return -1
#******* PROGRAM9.PY
import NUMBER
print("\t\t\tTo check palindrome numbers from a tuple ")
print("\t\t\t",'*' * 45)
t=tuple()
n=int(input('Enter the no.of entries:'))
for i in range(n):
num=int(input('Enter a number:'))
t+=(num,)
for i in t:
if NUMBER.palindrome(i)==1:
print(i,'is a palindrome')
else:
print(i,'is not a palindrome')