Python 3 Script to Find Armstrong Number in an Interval Using While Loop Full Tutorial For Beginners

Python 3 Script to Find Armstrong Number in an Interval Using While Loop Full Tutorial For Beginners

 

Welcome folks today in this post we will be finding armstrong numbers between an interval in python. All the full source code of application is given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

See also  Python PyQt5 to Build a Camera Selfie Picture Webcam GUI Desktop App Full Project For Beginners

 

app.py

 

 

lower = int(input("enter a lower number in range: "))
upper = int(input("enter a upper number in range: "))

for num in range(lower, upper + 1):

   # order of number
   order = len(str(num))
    
   # initialize sum
   sum = 0

   temp = num
   while temp > 0:
       digit = temp % 10
       sum += digit ** order
       temp //= 10

   if num == sum:
       print(num)

 

See also  Python 3 Script to Build Secure VPN For Browser to Open Websites in Window,Linux & IOS Full Project For Beginners

 

Now if you execute the python script by typing the below command

 

python app.py

 

 

 

Leave a Reply