TASK
1. NEON NUMBER:
A neon number is a number where the sum of the digits of its square is equal to the number itself
eg:
9^2=>81
8+1=>9 (neon number)
12^2=>144
1+4+4=>9 (not a neon number)
def sum_of_digit(no):
sum=0
a=0
while no>0:
a=no%10
sum=sum+a
no=no//10
return sum
no=int(input("enter a number"))
sq=no**2
result=sum_of_digit(sq)
if no==result:
print(f'{no} this is neon number')
else:
print(f' {no} this is not a neon number')
output:
enter a number9
9 this is neon number
2. Strong number:
A Strong number is a number equal to the sum of the factorials of its digits and its equal to the number itself
eg: number = 145
1!+4!+5!
1+24+120=145
def fact(no):
facto=1
while no>0:
facto=facto*no
no=no-1
return facto
def sum_digit(no):
sum=0
a=0
while no>0:
a=no%10
factorial=fact(a)
sum=sum+factorial
no=no//10
return sum
no=int(input("enter a number:"))
result= sum_digit(no)
if result==no:
print(f'{result} is a strong number')
else:
print(f'{result} is not a strong number')
output:
enter a number:145
145 is a strong number
enter a number:123
9 is not a strong number
3. Duck number
A number should not start with 0 and a number atleast contain a one 0
no=input("enter a number")
if no[0]=='0':
print(f'{no} is not a duck number')
else:
print(f'{no} is a duck nunber')
output:
enter a number0134
0134 is not a duck number
enter a number10234
10234 is a duck nunber
4. Spy number:
A Spy Number is a number where the sum of its digits equals the product of its digits.
def sum_of_digit(no):
sum=0
a=0
while no>0:
a=no%10
sum=sum+a
no=no//10
return sum
def mul_of_digit(no):
mul=1
a=0
while no>0:
a=no%10
mul=mul*a
no=no//10
return mul
no=int(input("enter a number: "))
sum=sum_of_digit(no)
mul=mul_of_digit(no)
if sum==mul:
print(f'{sum} and {mul} are spy number')
else:
print(f'{sum} and {mul} are not spy number')
output:
enter a number: 123
6 and 6 are spy number
enter a number: 456
15 and 120 are not spy number
Top comments (0)