12.Write a Python program to Check whether the given number is armstrong or Not from n Number.

Solution :- 

Static :- 

lower = 1
upper = 1000

for num in range(lower,upper+1):
sum = 0
temp = num
while temp>0:
rem = temp % 10
sum += rem*rem*rem
temp = temp //10
if num == sum:
print(num)

Output :- 

 

Dynamic :- 

lower = int(input(“Enter lower range :- “))
upper = int(input(“Enter upper range :- “))

for num in range(lower,upper+1):
sum = 0
temp = num
while temp>0:
rem = temp % 10
sum += rem*rem*rem
temp = temp //10
if num == sum:
print(num)

 

Output :-