Question

In: Computer Science

#Python: A palindrome is a sequence of characters that reads the same backwards as forwards. For...

#Python:

  1. A palindrome is a sequence of characters that reads the same backwards as forwards. For example, ‘Eve’, ‘madam’, and 20502, are palindromes. Write a function called testPalindrome() that asks the user to input a string and returns if that string is a palindrome with the output as follows, without red:

>>>

Please enter a string: eve

Your string "eve" is a palindrome.

>>> testPalindrome()

Please enter a string: end

Your string "end" is not a palindrome.

>>> testPalindrome()

Please enter a string: 100921

Your string "100921" is not a palindrome.

>>> testPalindrome()

Please enter a string: 10401

Your string "10401" is a palindrome.

>>>

Solutions

Expert Solution

I have written the program using PYTHON PROGRAMMING LANGUAGE.

OUTPUT :

CODE :

#function definition for testPalindrome

def testPalindrome(input_string):

temp = list(input_string)#converting string to list

temp.reverse()#to reverse the input string

if(temp == list(input_string)):

return True#return True

else:

return False#return False

#To take the user input for string

input_string = input("Enter a string : \t")

print("\nOUTPUT : ")

#calling testPalindrome function by passing the input string

if(not(testPalindrome(input_string))):

#print statement

print("Your string "+input_string+" is not a Palindrome.")

else:

#print statement

print("Your string "+input_string+" is a Palindrome.")

Thanks..


Related Solutions

making a python code for this: A palindrome is a sequence that reads the same backwards...
making a python code for this: A palindrome is a sequence that reads the same backwards as forwards. Numbers can also be palindromes if we consider their digits as a sequence, for example 12121 and 8228 are palindromes. We can find palindromes from an initial seed number using the reverse and add method: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number...
IN JAVA - [(1)] A palindrome is a string that reads the same forwards as backwards....
IN JAVA - [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty...
2. Palindromes A palindrome is a word that reads the same forwards and backwards. For example,...
2. Palindromes A palindrome is a word that reads the same forwards and backwards. For example, \aibohphobia" (the irrational fear of palindromes) is a word that reads the same forwards and backwards. Write a function called isPalindrome() that accepts a string as a parameter and returns True if the string is a palindrome, False otherwise. Using the function you created, write a program Python home work Python
A palindrome prime is a prime number that reads the same forwards or backwards. An example...
A palindrome prime is a prime number that reads the same forwards or backwards. An example of a palindrome prime is 131. Write a method with the following signature for determining if a given number is a palindrome prime. public static boolean isPallyPrime(int nVal) Note: For this assignment you are not allowed to use the built in Java class Array as part of your solution for any of these questions. Your Method signatures must be the same as given here.
python question A word is a palindrome if it the same read forwards and backwards. We...
python question A word is a palindrome if it the same read forwards and backwards. We will call a word a fuzzy palindrome if it is the same read forwards and backwards, except for possible differences in case. For example, both 'tattarrattat' and 'TaTtArRAttat' are fuzzy palindromes. Define a function is_fuzzy_palindrome that returns True if and only if its argument is a fuzzy palindrome. This method may be useful: S.lower() -> str : Return a copy of the string S...
In Java A palindrome is a word or sequence of characters which reads the same backward...
In Java A palindrome is a word or sequence of characters which reads the same backward and forward, such as madam, dad, racecar, 5885. In java Write a program that asks user to enter a word and prints if the word is a palindrome or not.
A Palindromic number is one that reads the same backwards and forwards. Write a MATLAB function...
A Palindromic number is one that reads the same backwards and forwards. Write a MATLAB function (call it palin.m) that takes as input a positive integer, and returns 1 (true) if it is palindromic, 0 (false) if it is not.  
C++: A palindrome is a word, phrase, number, or other sequence of characters which reads the...
C++: A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Sentence-length palindromes may be written when allowances are made for adjustments to capital letters, punctuation, and word dividers, such as "A man, a plan, a canal, Panama!", "Was it a car or a cat I saw?" or "No 'x' in Nixon". Write a program using Stacks-Array and Queue-Array data structure we did in class to...
1. A finite sequence of letters is called a palindrome if it reads the same forward...
1. A finite sequence of letters is called a palindrome if it reads the same forward or backward. Devise an algorithm for determining whether or not a string of n letters is a palindrome. Write your algorithm using the the same sort of pseudocode used in the text. Your algorithm should start with procedure palindrome (a1,a2,...,an: lowercase letters) Your procedure should return the value 0 if the string is a palindrome, and the first integer i such that ai 6=an−i+1...
Please provide Python code that does the following: 2) A palindrome is any sequence of characters...
Please provide Python code that does the following: 2) A palindrome is any sequence of characters that reads the same backwards as forwards. One-word examples include: Dad madam rotor Kayak redder noon For the sake of this exercise, the following may also be considered one-word palindromes: 1881 zap4554paz That is, numeric strings and “nonsense” strings that read the same backwards as forwards should be classified as palindromes. Write a program that takes as input a string and determines if it’s...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT