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
postnew [5]
3 years ago
9

Write a program that prompts the user for a word or phrase, and determines if the entry is a palindrome. A palindrome is a word

or phrase which reads the same forwards and backwards. For example, if the user entered: madam the program should display: That is a palindrome Your program should ignore spaces, commas, and apostrophes, and ignore differences between upper and lower case. For example, the phrase: Madam, I'm Adam would be considered a palindrome.
Computers and Technology
1 answer:
vekshin13 years ago
7 0

Answer:

Explanation:

The following code is written in Python. It asks the user for an input. Then cleans the input using regex to remove all commas, whitespace, and apostrophes as well as making it all lowercase. Then it reverses the phrase and saves it to a variable called reverse. Finally, it compares the two versions of the phrase, if they are equal it prints out that it is a palindrome, otherwise it prints that it is not a palindrome. The test case output can be seen in the attached picture below.

import re

phrase = input("Enter word or phrase: ")

phrase = re.sub("[,'\s]", '', phrase).lower()

reverse = phrase[::-1]

if phrase == reverse:

   print("This word/phrase is a palindrome")

else:

   print("This word/phrase is NOT a palindrome")

You might be interested in
Rachelle's computer has frequent system crashes and it takes a long time to access files and folders. What hardware component is
9966 [12]
System crashes, viruses and fragmented file systems are hallmarks of Windows systems, but your teacher is probably looking for Hard Drive for the answer.
8 0
3 years ago
3.1.5 Which network component connects a device to transmission media and allows the device to send and receive messages?
Rom4ik [11]

Answer:

Network Interface Card (NIC)

Explanation:

Also called Ethernet Card, the Network Interface Card (NIC) allows a computer or any device to make wired or wireless connections with other devices in a network. This connection made possible by the NIC allows the device to send and receive messages in the network.

An application of this is seen in Internet of Things(IoT) where devices communicate with one another. This is actually possible because all of the devices one way or the other have a network interface card.

8 0
3 years ago
Smith wants to get a job in network systems. Which major should he choose to give him the best chance of getting a job?
Sever21 [200]
<span>computer engineering</span>
5 0
4 years ago
Read 2 more answers
Whatisthebestlocationapp for my androidphonebesidesgoogle maps?
Cerrena [4.2K]
Not sure whether this question is requires a specific answer but I would say Waze.
3 0
4 years ago
hi, I want to ask how do I change the Brainly to another country?, because I pressed the wrong Brainly button to my country​
Setler [38]

Answer:

I don't know maybe you should Uninstall

3 0
3 years ago
Read 2 more answers
Other questions:
  • What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
    13·1 answer
  • Consider that a large online company that provides a widely used search engine, social network, and/or news service is consideri
    12·1 answer
  • Assume you have taken another square picture with the 25-megapixel digital camera discussed in the previous question. This time
    8·1 answer
  • In which of the following scenarios would you use the Redo function?
    12·1 answer
  • What image format should be used to keep the file size manageable​
    14·1 answer
  • Why would "ExpirationDate” be a poor choice as a primary key?
    11·1 answer
  • True or False (type the entire word)
    11·1 answer
  • What symbol precedes all structured references in formula autocomplete lists?
    15·1 answer
  • Drag the correct type of update to its definition.
    13·1 answer
  • (1) Prompt the user to input an integer between 32 and 126, a float, a character, and a string, storing each into separate varia
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!