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
Vector graphics are composed of solid __________,curves and other __________ shapes​
serious [3.7K]

Answer:

Lines; geometric.

Explanation:

Graphic design can be defined as an artistic process used for the creation of art works such as logos.

In the creation of various graphic files such as in 2-D or 3-D we can use a variety of software applications or programs such as Blender basics, Adobe photoshop, illustrator, Coreldraw, etc.

Graphic design involves the use of vector graphics, bitmap graphics or raster graphics.

Vector graphics are composed of solid lines, curves and other geometric shapes that are typically defined by series of mathematical instructions. Thus, vector graphics can be scaled to a smaller or larger size without any change in its quality.

5 0
3 years ago
if a user watches a video with event tracking three times in a single session, analytics will count how many unique events?
Lyrx [107]

Answer:

1

Explanation:

Analytics will count it a One (‘1’) Unique Event, even if a user watches a video with event tracking three times but in a single session.

8 0
2 years ago
1. Consider the numbers 23.724 and 0.3344770219. Please normalize both. 2. Calculate their sum by hand. 3. Convert to binary ass
elena-s [515]

Answer:

please see explaination and attachment

Explanation:

Normalization is a database design technique that organizes tables in a manner that reduces redundancy and dependency of data. Normalization divides larger tables into smaller tables and links them using relationships.

see attachment for the step by step solution

7 0
3 years ago
What are the benefits of having Friends who are different from us
AURORKA [14]

You shouldn't judge anyone who is "different" because everyone's the same so the benefit would just be that you would have a friend

7 0
3 years ago
1)A popular and useful tool for strategic planning is SWOT analysis. SWOT stands for
Blizzard [7]

1. strengths, weakness, opportunities, threats

2. protecting the privacy of others

3. this behavior can create divisions on the team.

4. creating a schedule for workflow

7 0
4 years ago
Other questions:
  • You work at a computer repair store. You just upgraded the processor (CPU) in a customer's computer. The computer starts, but it
    11·2 answers
  • Course hero 21. say you have a /15 network address. you are asked to create subnets with at least 1,000 hosts/ subnet. what is t
    9·1 answer
  • MULTIPLE CHOICE!!!
    5·2 answers
  • What scheme is usually used today for encoding signed integers?
    5·1 answer
  • The UNIX system does not attempt to avoid cycles. Instead, it restricts access to the linking capability of the system. Normal u
    11·1 answer
  • Sam wants to use the rule of thirds to capture the essence of his image. How will he apply this rule in his image to get a pleas
    6·1 answer
  • Why is proper planning important?
    10·1 answer
  • You’ve found the file you’ll be working with. Next, you decide to move the file to your Desktop so it will be easier to get to i
    14·1 answer
  • Do you know how to change your grades on a printer???????????
    13·1 answer
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!