Answer to Question #224589 in Python for Hari nadh babu

Question #224589

Armstrong numbers between two intervals


This Program name is Armstrong numbers between two intervals. Write a Python program to Armstrong numbers between two intervals, it has two test cases


The below link contains Armstrong numbers between two intervals question, explanation and test cases


https://drive.google.com/file/d/1nMwnGgwxLey1JhQEaQ_x-goS5_1DyVdL/view?usp=sharing


We need exact output when the code was run

1
Expert's answer
2021-08-10T04:29:15-0400
A = int(input("enter value of A: "))
B = int(input("enter value of B: "))


for num in range(A, B + 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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS