S.Y.I.T Sem 3 Python Practical | Python| Python practical 1e| Write a function to check the input value is Armstrong and also write the function for Palindrome.| python for beginner
Hello reader's
In this post you are going to see that how you can check that the giver number Armstrong or not and Palindrome or not. For understanding this you must know about Armstrong number and Palindrome number. Let's what is Armstrong number and Palindrome number.
What is Armstrong number?
The Armstrong number definition is the number in any given number base, which forms the total of the same number, when each of its digits is raised to the power of the number of digits in the number.
A number is called an Armstrong number when the number ABCD = A^n+ B^n+ C^n+ D^n
Where n is the total number that is n=ABCD.
Let's understand it with a example:-
Take a number 1634. Now we have to check that the number 1634 is Armstrong or not.
According to formula ABCD = A^n+ B^n+ C^n+ D^n
Where n is the total number that is n=ABCD
1634 = 1^4 + 6^4 + 3^4 + 4^4
1634 = 1 + 1296 + 81 + 256
1634 = 1634 , which means that the number 1634 is a Armstrong number.
You can also try with some other numbers like - 153, 371, 9474 etc.
Now the next topic is Palindrome number. Do you know what is Palindrome number?
What is palindrome number ?
A number is called Palindrome when the reverse of the number is equal to the original number.
Lets understand it with a example :-
Lets suppose number 1234. Now we have to check that the number 1234 is Palindrome or not.
according to definition , number must be equal to reverse of it, therefore the number
1234 = Reverse of the nuber
1234 = 4321 (which is not equal)
So the given number 1234 is not a palindrome number.
Let's one more example , The number is 2002
2002 = Reverse of the number
2002=2002
So the above given numbers 2002 are called as palindrome number.
Palindrome number |
Comments
Post a Comment
Thank you for sharing this.
You’re helping us become better. Want to stay in the loop? Subscribe to our YouTube channel.