num-int(input("Enter the required number"))
temp=num
reverse=0
while num>0:
remainder=num%10
reverse=(reverse* 10)+remainder
num=num//10
print(reverse)
Method2:
num=1234
print(str(num)[::-1])
program9:
Write a python program to check for Palindrome or not.
Method1: Using simple Iteration.
Palindromic Numbers:
The Numbers that when reversed is the same as the original number itself are known
as palindromic Numbers.
Example:
123321 and the reverse of the number is same.
Method1: Simple iteration method(using while loop)
Method2: String slicing
Method3: Using character matching.
Program10:
Check whether a Given Number is Armstrong Number or not.
Number=371.
Armstrong Numbers in Python:
The Numbers that can be represented as the 'sum of the digits raised to the power
of the number of digits in the number' are called Armstrong numbers.
Example:
Input: 1634
Output: 1634(1^4+6^4+3^4+4^4)
number=371
temp=number
digit,sum=0,0
length=len(str(number))
for i in range(length):
digit=int(number%10)
num=num/10
sum+=pow(digit,length)
if sum==temp:
print("Armstrong")
else
print("Not Armstrong")
_____________________________
Strong Number
Perfect number
Perfect square
automorphic number
Harshad number
Abundant number
friendly pair
_____________________________
Automorphic Number:
A number whose square ends with the same number is known as the Automorphic Number.
number=int(input("Enter required number"))
square=pow(number,2)
mod=pow(10,len(str(number)))
if square%mod==number:
print("It is an Automorphic Number")
else:
print("it is not an Autorphic nUmber")
Method2:
n=int(input("Enter the required number"))
print("Yes" if int(str(n**2)[len(str(n))::-1])==n else "No")
Program11:
Check whether the Number is Harshad or not using Python.
Harshad Number:
A number that is divisible by the sum of it's digits is known as a Harshad number.
Example:
Input:21
output: It's Harshad Number.
Program13: Abundant Number
A number that is smaller than the sum of all its factors except the number itself
is known as an Abundant number.
Program14:
Strong number:
A number that is equal to the sum of the factorial of its individual digits is
known as Strong number.
Example:
Input: 145
n=int(input("Enter a number:"))
temp=n
sum=0
while n>0:
fact=1
d=n%10
for i in range(1,d+1)
fact=fact*i
sum+=fact
n=n//10
if(sum==temp):
print("strong")
else:
print("not strong")
Program14:Friendly Pair Numbers
The numbers whose(sum of divisors)/number ratio is the same are known as Friendly
pair numbers.
n
Program15:
Perfect Square.
A perfect square is a number that can be expressed as the product of an integer by
itself
or as the second exponent of an integer.
Program16:
Perfect Number:
A number that can be represented as the sum of all the factors of the number is
known as a Perfect Number.
Task of the Day: