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
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...
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...
(Palindrome number - A number is a palindrome if it reads the same from right to...
(Palindrome number - A number is a palindrome if it reads the same from right to left and from left to right, for example 676 is a palindrome number) Write a program that prompts the user to enter a three-digit integer number and determines whether it is a palindrome number or not In Java Please
A palindrome is a string of characters (a word, phrase, or sentence) that is the same...
A palindrome is a string of characters (a word, phrase, or sentence) that is the same regardless of whether you read it forward or backward – assuming that you ignore spaces, punctuation and case. For example, Race car is a palindrome. So is A man, a plan, a canal: Panama. 1. Describe how you could use a stack to test whether a string is a palindrome. 2. Describe how you could use a queue to test whether a string is...
In C++: This is the problem: [(1)] A palindrome is a string that reads the same...
In C++: This is the problem: [(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...
1. A is called a palindrome if it reads the same from left and right. For...
1. A is called a palindrome if it reads the same from left and right. For instance, 13631 is a palindrome, while 435734 is not. A 6-digit number n is randomly chosen. Find the probability of the event that (a) n is a palindrome. (b) n is odd and a palindrome. (c) n is even and a palindrome.
A is called a palindrome if it reads the same from left and right. For instance,...
A is called a palindrome if it reads the same from left and right. For instance, 13631 is a palindrome, while 435734 is not. A 6-digit number n is randomly chosen. Find the probability of the event that (a) n is a palindrome. (b) n is odd and a palindrome. (c) n is even and a palindrome.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT