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
What is thisssssssss please answer
True [87]

Answer:

first of all, are you a snake? And also that is a spotlight.

Explanation:

3 0
3 years ago
Summarize the five stages of cultural shock
Anton [14]
1. Honeymoon stage
2. Distress and anxiety
3. Adjustment
4. Adaption
5. Re-entry shock
8 0
3 years ago
Read 2 more answers
Which of the following characters is acceptable to use in a filename
Rama09 [41]
You never stated the possible answer choices to your answer, but usually in a filename you can use all letters of the alphabet, but you cannot use any symbols. such as backslashes, percentage signs etc., but underscores you can use, since they can be used for spacing 2 seperate words.
4 0
3 years ago
Read 2 more answers
Multiple Choice
podryga [215]

Answer:

a

Explanation:

Boolean Operators are simple words (AND, OR, NOT or AND NOT) used as conjunctions to combine or exclude keywords in a search, resulting in more focused and productive results. ... Proximity Operators (with, near and others) can also help you in searching.

5 0
3 years ago
An organization that wishes to leverage the power of social media and elastic cloud opportunities to help accomplish its goals a
Kruka [31]

Answer:

The answer is "technology"

Explanation:  

In the ideal scenario, a company which needs to leverage social networking resources and open cloud tools to achieve its objectives and priorities must use the information systems division of all its IT team.

  • It is used to achieve goals through knowledge, techniques, and methods.
  • It typically serves as a generic term for computer and their networks, but it includes other IT technology, including TV and smartphones.
6 0
3 years ago
Other questions:
  • Which is most likely to cause confusion, hinder thinking, and prevent quick access to resources in a study environment? phones c
    5·2 answers
  • Unless you specify otherwise, excel summarizes data by ____.
    10·1 answer
  • Technician A says that a common type of spontaneous combustion occurs when rags or papers that are soaked in solvents end up in
    14·2 answers
  • You need to provide connectivity between two buildings without running any cables. You decided to use two 802.11ac APs to provid
    14·1 answer
  • Explain how a monitor can display the letters that you type on a keyboard. (Hint: Three Basic Computer Functions) *
    11·1 answer
  • Advantage of realtime processing​
    14·1 answer
  • Plz help
    8·1 answer
  • Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6
    13·1 answer
  • A router periodically goes offline. Once it goes offline, you find that a simple reboot puts the router back online. After doing
    12·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!