Python Question – 2
Armstrong Number
Any number, say ‘n’, is called an Armstrong number if it is equal to the sum of its digits, where each is raised to the power of the number of digits in ‘n’.
For example:
153=13+53+33
Code:
num=int(input()) 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("True") else: print("False")