Question
5b please
5. A Palindrome is a string that reads the same in both directions e.g. a level is level a. a) Write Python code that defin
0 0
Add a comment Improve this question Transcribed image text
Answer #1

5b)

1 def pal(s): return str(s) str(s[::-1]) 3 s-input(Enter the string ) 2 4 5 if pal(s)-True: 6 print(The entered string is

Output

Enter the string: 1233211 The entered string is not a palindrome

code for copying

def pal(s):
return str(s)==str(s[::-1])
s=input("Enter the string : ")

if pal(s)==True:
print("The entered string is a palindrome")
if pal(s)==False:
print("The entered string is not a palindrome")

Add a comment
Know the answer?
Add Answer to:
5b please 5. A Palindrome is a string that reads the same in both directions e.g....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • palindrome is a string that reads the same both forward and backward. C++ For example, the...

    palindrome is a string that reads the same both forward and backward. C++ For example, the string "madam" is a palindrome. Write a program that uses a recursive function to check whether a string is a palindrome. Your program must contain a value-returning recursive function that returns true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameters.

  • In C language: A palindrome is a string that reads the same forwards or backwards; for...

    In C language: A palindrome is a string that reads the same forwards or backwards; for example dad, mom, deed (i.e., reversing a palindrome produces the same string ). Write a recursive, bool-valued function, isPalindrome that accepts a string and returns whether the string is a palindrome.

  • C++ A palindrome is a string that reads the same backward as forward. For example, the...

    C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...

  • Please Code in Java and follow the directions given Thanks Program required Directions .A palindrome is a str...

    Please Code in Java and follow the directions given Thanks Program required Directions .A palindrome is a string that reads the same forward and backward, i.e., the letters are the same whether you read them from right to left or from left to right. Examples: 3 a) radar à is a palindrome b)Able was I ere I saw Elba à is a palindrome e good à not a palindrome Write java program to read a line of text and tell...

  • Palindrome is a word or a phrase when taken in reverse order, gives the same word...

    Palindrome is a word or a phrase when taken in reverse order, gives the same word or phrase. For example, the word “radar” is a palindrome. The phrase "Do geese see God?" is also a palindrome after the removal of the question mark and all the spaces and the conversion of the remaining alphabets to either upper or lower case. Write a program that uses an STL stack to check if an arbitrary string containing multiple words separated by spaces...

  • C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string cl...

    C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...

  • Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward...

    Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for...

  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here...

    A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for the user input....

  • PLEASE I NEED C# PROGRAM WITH DETAILS Objectives Apply recursion to a more difficult problem. Background...

    PLEASE I NEED C# PROGRAM WITH DETAILS Objectives Apply recursion to a more difficult problem. Background There are many problems that loops simplify, such as displaying every pixel to a screen or receiving repetitive input. However, some situations that can be simplified with looping are not easily solvable using loops. This includes problems that require back tracking and being able to use information from previous iterations, which would normally be lost when using an iterative loop. In those cases, it...

  • Assignment 1 Year 2 ICTEDU term 1 2019 For question 1 and 2 the report should...

    Assignment 1 Year 2 ICTEDU term 1 2019 For question 1 and 2 the report should consist the following sections on each task: Task Description: Pseudo code / Algorithm: Testing: implementation (working program) screenshots NOTE: Question 1 and 2 Attach a well commented C source file of the program in a zipped file QUESTION 1-Simple C functions 1. Write a short C function that takes an integer (year) and checks whether the year is a Leap Year or not. If...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT