Articles

Write a program to check if a number is neon number in python

Write a program to check if a number is neon number in python


In this python program guide, we will learn to write:

  • NEON NUMBER PROGRAM IN PYTHON

🧐🧐What is a Neon Number?

 

A number is said to be a neon number if the sum of the digits of the square of the number is equal to that number.

Our task is to check whether an inputted number is neon or not in python.

For example

9 is a neon number because 9*9=81(8+1=9)

here sum of the digits of the square of the number is equal to that number.

 

Now lets try to write neon number program in python.


πŸ“™πŸ“™ Neon number in python

Code for neon number program in python is given below:


# neon number program in python
while True:
    x=int(input("enter a no :"))  # for user input
    if(x==0):
        print("the program has been terminated")
        break  # to terminate the program 
    p=x**2
    sum=0
    while (p!=0):
        rem=p%10
        sum=sum+rem  # to store the sum of digits of the square of the number
        p=p//10
    if(sum==x):
        print("inputted no is neon")
    else :    
        print("inputted no is not neon number ")

 

πŸ‘‰πŸ‘‰The program will check whether the inputted no is neon number in python or not untill the user enters 0 as a number.When user inputs 0 as a number the program will be terminated.

 

πŸ€·β€β™€οΈπŸ€·β€β™€οΈπŸ€·β€β™€οΈOutput to the neon number in python is given below:



enter a no :6 
inputted no is not neon number 
enter a no :7 
inputted no is not neon number 
enter a no :9 
inputted no is neon 
enter a no :0 the program has been terminated

Screenshot of running  program in jupyter notebook:

 

neon number program in python

 

 

 

 

 

 

 

 

 

 

 

 

 

As you can see in the screenshot the neon number program in python is running successfully.

 

 πŸŽ―🎯🎯Thank you for reading this article. Please share if you find this article helpful to you.πŸ‘πŸ‘πŸ‘πŸ‘

 


Basic Python Programs
Python Conversion Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Ayush Bajpai
I am a data science enthusiast. I love to learn new technology πŸ› πŸ› .you can reach me at this url www.linkedin.com/in/ayushbajpai47
Page Views :    Published Date : May 06,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!