Armstrong Number in PYTHON


An Armstrong Number is a special kind of number in which the sum of their digits provided raise to the power of the number of digit is equal
for example:-
       153 is an Armstrong Number
        1^3+5^3+3^3=153
        #You can check out#
       1634 is also an Armstrong Number
       1^4+6^4+3^4+4^4=1634

Let's check the coding behind it.. 

no=int(input ("enter the no:")) 
dig=len(str(no)) 
temp=no
sum=0
while temp>0:
            d=temp%10
            sum=sum+d**dig
            temp=temp//10
if sum==no:
            print("Yes it's an Armstrong Number") 
else:
            print("Sorry! it's not try another one ") 




OUTPUT:

enter the no:153
Yes it's an Armstrong Number

enter the no:1634
Yes it's an Armstrong Number

enter the no:1234
Sorry!it's not try another one

Comments

  1. Need some introduction to python for beginners.
    For me😀

    ReplyDelete
  2. Try posting "raspberry pi" codes.
    They are trending🔥 now.

    ReplyDelete

Archive

Contact Form

Send