Knowee
Questions
Features
Study Tools

Write a programme to check whether given input is palindrome or notConstraintsABC != PalindromeMAM == Palindrome123 != Palindrome151 == PalindromeTest CasesSample -1InputMAMOutPutMAM is a palindrome Sample -2Input123OutPut123 is not a palindrome Sample -3Inputabc123cbaOutPutabc123cba is not a palindrome Topics Covered

Question

Write a programme to check whether given input is palindrome or notConstraintsABC != PalindromeMAM == Palindrome123 != Palindrome151 == PalindromeTest CasesSample -1InputMAMOutPutMAM is a palindrome Sample -2Input123OutPut123 is not a palindrome Sample -3Inputabc123cbaOutPutabc123cba is not a palindrome Topics Covered

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Python program that checks if a given input is a palindrome or not:

def is_palindrome(input_string):
    # Reverse the input string
    reversed_string = input_string[::-1]
    
    # Compare the reversed string with the original string
    if input_string == reversed_string:
        return True
    else:
        return False

# Test the function with some inputs
input_string = "MAM"
if is_palindrome(input_string):
    print(input_string, "is a palindrome")
else:
    print(input_string, "is not a palindrome")

input_string = "123"
if is_palindrome(input_string):
    print(input_string, "is a palindrome")
else:
    print(input_string, "is not a palindrome")

input_string = "abc123cba"
if is_palindrome(input_string):
    print(input_string, "is a palindrome")
else:
    print(input_string, "is not a palindrome")

This program defines a function is_palindrome that takes an input string, reverses it, and then checks if the reversed string is the same as the original string. If they are the same, the function returns True, indicating that the input is a palindrome. Otherwise, it returns False.

The program then tests this function with three different inputs: "MAM", "123", and "abc123cba". For each input, it calls the is_palindrome function and then prints out whether the input is a palindrome or not.

This problem has been solved

Similar Questions

Write a python program to check the given string is palindrome or not.

Write a Java program to check whether a given word is a palindrome or not. for e.g. MADAM is a palindrome but eat is not.

Problem StatementSusi loves playing with numbers and exploring their unique properties. One day, she learned about palindromic numbers and decided to write a program to check if a given number is a palindrome or not. Can you help her accomplish this task using a while loop?Note: palindrome is a number that is the same when reversed. For example, 121, 1331, and 45654 are palindromic numbers.Input format :The input consists of a single integer, n, where n is the number that Susi wants to check for palindromic properties.Output format :The output displays one of the following messages:"Palindrome" if n is a palindrome."Not a Palindrome" if n is not a palindrome.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:11 ≤ n ≤ 106Sample test cases :Input 1 :2552Output 1 :PalindromeInput 2 :1234Output 2 :Not a PalindromeInput 3 :11Output 3 :PalindromeInput 4 :1000000Output 4 :Not a Palindrome

Your friend is in university and there is a coding challenge going on. A string S of lowercase letters is displayed over the screen. The length of the string is N. An integer M is also displayed over the screen.Your task is write a program to determine if we can make the string Palindrome by performing at most M operations on the provided string

class Solution { public boolean isPalindrome(int x) { String num =Integer.toString(x); for(int i=num.length()-1;i<0;i--){ String a =" "+num; if(num==a){ System.out.println("it is palindrome:"+a); }else{ System.out.println("it is not palindrome:"+a); } } }}

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.