-
Notifications
You must be signed in to change notification settings - Fork 0
/
1e.py
32 lines (32 loc) · 861 Bytes
/
1e.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Python program to check if the number provided by the user is an Armstrong
#number or not
def armstrong(num):
sum=0
# find the sum of the cube of each digit
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
# display the result
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
def palindrome(num):
n = num
rev = 0
while num != 0:
rev = rev * 10
rev = rev + int(num%10)
num = int(num / 10)
if n == rev:
print(n,"is palindrome number")
else:
print(n,"is not a palindrome")
# take input from the user
num = int(input("Enter a number to check it is armstrong or not: "))
armstrong(num)
# take input from the user
num = int(input("Enter a number to check it is palindrome or not: "))
palindrome(num)