#checking a number is armstrong or not using functions
import math #importing the math module
def armstrong(num,c): #defining a function for checking the number
sum=0
while(num>0):
r=num%10
p=math.pow(r,c)
sum=sum+p
num=num//10
return sum
nu=int(input("enter any numer"))
result=armstrong(nu,c)
if(result==nu):
print("armstrong")
else:
print("not a armstrong")
import math #importing the math module
def armstrong(num,c): #defining a function for checking the number
sum=0
while(num>0):
r=num%10
p=math.pow(r,c)
sum=sum+p
num=num//10
return sum
nu=int(input("enter any numer"))
result=armstrong(nu,c)
if(result==nu):
print("armstrong")
else:
print("not a armstrong")
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. python training in chennai
ReplyDelete