Python : Armstrong Numbers in a Range

Introduction : In this blog you will find how can you get Armstrong number in a range using python.
Code: 
  1. lower_Range = int(input("Enter lower range : "))  
  2. upper_Range = int(input("Enter upper range : "))  
  3.   
  4. for n in range(lower_Range,upper_Range + 1):  
  5.    sum = 0  
  6.    temp = n  
  7.    while temp > 0:  
  8.        digit = temp % 10  
  9.        sum = sum + digit ** 3  
  10.        temp = temp // 10  
  11.   
  12.    if n == sum:  
  13.        print(n)    
Output :

 
Ebook Download
View all
Learn
View all
sourabhsomani.com