V-Lab @ ANDC

To check whether a word is palindrome or not

Aim

To check whether a word is palindrome or not

Theory

A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers. It can also be a string like LOL, MADAM etc.
A palindromic number (also known as a numeral palindrome or a numeric palindrome) is a number (such as 16461) that remains the same when its digits are reversed. In other words, it has reflectional symmetry across a vertical axis. The term palindromic is derived from palindrome, which refers to a word (such as rotor or racecar) whose spelling is unchanged when its letters are reversed.

Algorithm

    1. Get the number to check for palindrome.
    2. Hold the number in temporary variable.
    3. Reverse the number or word.
    4. Compare the temporary number with reversed number or word.
    5. If both numbers or words are same, print "palindrome number or word".
    6. Else print "not palindrome number/ word".

Practice

Enter the word or number:

Here's the result




Python Code

                        
                            # Python code for cheking the condition of Palindrome
                            def isPalindrome(s):
    return s == s[::-1]
 
# Driver code
s = "malayalam"
ans = isPalindrome(s)
 
if ans:
    print("Yes")
else:
    print("No")

                        
                    

Result

Hence we can chekc whether a word or number is palindrome or not.