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
What Windows PowerShell commands should you use to create a simple volume of the same size on disk 3 using the drive letter G:?
emmainna [20.7K]
The solution for this problem is 

<span>Create a new partition on disk 1

</span>PS C:\> New-Partition -DiskNumber 1<span> -UseMaximumSize -AssignDriveLetter
</span>
This command lets you create a new partition disk and the same time uses the maximum available space as well as the automatically assigning it into a drive.
7 0
3 years ago
Which one of the following terms is defined as the material and surfaces upon which an artist works?1. Applied arts2. Context3.
babunello [35]

Answer:

The correct answer to the following question will be Option D (Media).

Explanation:

Media are the contact channels or devices used to store information or data and distribute it. The phrase refers to elements of the media marketing industry such as printed media, printing, mainstream media, film, theater, television and radio broadcast, and advertisement.

There are mainly three types of media, which are as follows:

  • Print media
  • Broadcast media
  • Internet

Using these three media, we can describe the content and the surfaces on which an artist works.

Therefore, Option D is the right answer.

5 0
3 years ago
You are configuring NIC teaming on a server with two network adapters. You chose Switch Independent Mode. You now must choose be
zmey [24]

Answer:

The appropriate answer is "Active/Active mode".

Explanation:

  • Now just after the customers or clients respond to the traditional standards, the board is comprised the information rapport with the cloud service, which would be considered as Active mode.
  • The car glides primarily somewhere at a specified constantly controlled rate of the conductor. Currently entering the grounding connection boosts the flow of electrons further into the receiver as well as the transmitter.

Thus the above is the correct solution.

3 0
3 years ago
The ____ dialog box provides options for moving charts between worksheets and chart sheets.
Tresset [83]
The move chart dialog box provides options for moving charts between worksheets and chart sheets.

So the correct answer is A.

Hope this helps :)
~Davinia.
4 0
3 years ago
Apply the fade transition with smoothly effect to all slides in the presentation​
Hunter-Best [27]

Answer:

12

Explanation:

its very long answer so that it is that

7 0
3 years ago
Other questions:
  • what important technology has done the most to allow small businesses a change to compete with larger international companies?
    5·1 answer
  • Why should spain go to Africa ​
    15·1 answer
  • Up to 10 people is a good guideline for the size of your study group.
    15·1 answer
  • A(n) _____ allows a user to choose specific files to back up, regardless of whether or not the files have been changed.
    9·1 answer
  • Hi im new and would like you to answer​
    13·1 answer
  • Which view shows how the document will look when printed?
    11·1 answer
  • Which command should you enter to configure a single port to discard inferior bpdus 200-125?
    5·1 answer
  • Validation ensures that a website looks good.<br> True or False
    9·1 answer
  • Universal Containers has a custom picklist filed with three values on their products. The Admin would like to create a Dynamic B
    10·1 answer
  • Examine the efficiency the various recovery algorithms used in deadlock handling
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!