1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
EastWind [94]
3 years ago
7

Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of

characters that reads the same as the sequence in reverse; for example, noon.
Computers and Technology
1 answer:
Maslowich3 years ago
8 0

Answer:

Here the code is given as follows,

Explanation:

def isPalindrome(x):

   stack = []

   #for strings with even length

   if len(x)%2==0:

       for i in range(0,len(x)):

           if i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True

   #for strings with odd length    

   else:

       for i in range(0,len(x)):

           if i==int(len(x)/2):

               continue

           elif i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True  

def main():  

   while True:  

       string = input("Enter a string or Return to quit: ")  

       if string == "":  

           break  

       elif isPalindrome(string):  

           print("It's a palindrome")  

       else:  

           print("It's not a palindrome")  

if __name__ == '__main__':  

   main()

You might be interested in
Specialization of computer engineering ?<br>​
Juliette [100K]

Answer:

Mobile Device Design.

Embedded Systems Design.

Microprocessor Design.

Academic Research.

Proprietary Research.

6 0
3 years ago
How many of yall are willing too sub to my channel called "Space Juice" with around 200 subs?!​
EastWind [94]

Answer:

I would love to, but my mom wont let me watch you-tube because i am so tech  savi that i figured out a way to watch you-tube on a blocked school district computer.

Explanation:

i need brainliests

7 0
3 years ago
What are the two major categories of computer software? word-processing software and spreadsheet software applications software
Strike441 [17]
From this list, the most used software would be:

Word-processing software and spreadsheet software.
5 0
4 years ago
What is the introduction of an algorithm and programming and how does it work?
rewona [7]

Answer:

A programming algorithm is a procedure or formula used for solving a problem. It is based on conducting a sequence of specified actions in which these actions describe how to do something, and your computer will do it exactly that way every time. An algorithm works by following a procedure, made up of inputs. Explanation:

5 0
3 years ago
The wired or wireless means of connecting a computer to the internet is called a ________.
viktelen [127]
The wired or wireless that means of connecting a computer to the internet is called :  B. physical connection
In computers, physical connection does not necessarily physical. It is the medium that do the direct connect to the internet

hope this helps

7 0
3 years ago
Other questions:
  • This is more opinionated than question-based.
    7·1 answer
  • Select the correct answer,
    12·1 answer
  • Your electric service has been failing with some frequency lately because of a lot of storms, and you are looking for more peace
    14·1 answer
  • Fill in the blank <br>computers are closed in......​
    6·1 answer
  • 5-16) (Bar Chart Printing Program) One interesting application of computers is to display graphs and bar charts. Write an applic
    10·1 answer
  • Ask the user to input an integer. Print out the next three consecutive numbers.
    14·2 answers
  • What can help you estimate how much money you might get in
    7·1 answer
  • By what other name can the folders in Windows 7 be called?
    5·1 answer
  • HOMEWORK: Bud, Not Buddy I NOTICE... What do you see? chpter 3-4<br><br>​
    14·1 answer
  • Text to appear
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!