Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
Question
Book Icon
Chapter 13, Problem 3PE
Program Plan Intro

Palindrome

Program plan:

  • Define a function “palindrome()”.
    • If the condition “firstRun == True”is true.
    • Iterate a for loop.
      • Call a function “replace()”.
    • Call the function “lower()”.
    • If the condition “len(xStr) < 2”is true.
      • Return true
    • Check another condition “xStr[0] == xStr[-1]”.
      • Set the value of “xStr”.
      • Call the function “palindrome()”.
      • Return true.
    • If the conditions do not satisfy
      • Return false
  • Define “main()” function.
    • Scan for the input values.
    • If the condition is true
      • Print the statement.
    • If the condition is not true.
      • Print the statement.
  • Calling the main function

Blurred answer
Students have asked these similar questions
Write a recursive function to print all the permutations of a string. For example, for the string abc, the printout is:abcacbbacbcacabcba(Hint: Define the following two functions. The second function is a helper function.def displayPermuation(s):def displayPermuationHelper(s1, s2): The first function simply invokes displayPermuation(" ", s). The secondfunction uses a loop to move a character from s2 to s1 and recursively invokes t with a new s1 and s2. The base case is that s2 is empty and prints s1 to the console.)Write a test program that prompts the user to enter a string and displays all its permutations.
S is a set of strings recursively defined as follows. Base case: Every variable from the set {a, b, c, d, e, f} is in S. Recursive rules: If x = S and y = S, then: 1. (x + y) Є S 2. x.yЄ S Indicate which expressions are in S. ☐ (d.e.a) a+b a.b.c ☐ (a + d).e
c++   A palindrome is a string that reads the same both forward and backward. 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 parameter.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT