Page 351 - Information_Practice_Fliipbook_Class11
P. 351
sumCubeDigits += (n % 10) * (n % 10) * (n % 10)
n //= 10
if num == sumCubeDigits:
print(num,"is an Armstrong number.")
else:
print(num,"is not an Armstrong number.")
Program 20: Write a program that takes a number as an input and checks whether it is a palindrome or not. A
palindromic number (also known as a numeral palindrome or a numeric palindrome) is a number (such as 16461) that
remains the same when its digits are reversed.
Ans. '''
Objective: To check whether a number is a palindrome
Input: num
Output: result whether it is a palindrome or not
'''
num = int(input("Enter a Number: "))
n = num #storing the number for later usage
reverseNum = 0
remainder = 0
while num > 0:
remainder = num %10
reverseNum = reverseNum * 10 + remainder
num //= 10
if n == reverseNum:
print("Given number is a palindrome")
else:
print("Given number is NOT a palindrome")
Program 21: Write a program that takes a number as an input and checks whether it is prime or not. Prime numbers
are natural numbers that are divisible by only 1 and the number itself.
Ans. '''
Objective: To check whether a number is a prime number
Input: num
Output: result whether it is prime or not
'''
num = int(input("Enter a Number: "))
upperLimit = num
Practical 337

