Write a menu-driven program to perform the following:
i. Check whether a number accepted by the user is an Armstrong Number or not.
ii.Check whether a number accepted by the user is Palindrome or not
Pls answer it fast
Answers
Answered by
4
def is_armstrong(n):
_sum = 0
digits = list(map(int, str(n)))
for d in digits:
_sum += d ** 3
return "an armstrong" if n == _sum else "not an armstrong"
def is_palindrome(n):
return "a palindrome" if str(n) == str(n)[::-1] else "not a palindrome"
n = int(input("enter num: "))
print(f"{n} is {is_armstrong(n)} number!\n{n} is {is_palindrome(n)} number!")
Similar questions
English,
2 months ago
Biology,
2 months ago
Computer Science,
2 months ago
Math,
11 months ago
Math,
11 months ago
Social Sciences,
11 months ago