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]
2 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:
vekshin12 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
PLEASE HELP I WILL REWARD YOU
xxMikexx [17]
What what what what what what
5 0
3 years ago
Match the image to its type.
boyakko [2]

Warm Colors:

  • <em>Red</em> flowers
  • Oranges

Cool Colors:

  • <em>Blue </em>skies
  • <em>Purple</em> butterflies

Neutral Colors:

  • <em>Brown</em> wood
  • <em>White</em> birds

Reds, oranges, and yellows are considered warm, and greens, teals, blues, and purples are considered cool. Colors such as white, black, brown, or gray are all neutral.

3 0
3 years ago
Write a function sample_median(n,P) that generates n random values using distribution P and returns the median of the collected
TiliK225 [7]

Answer:

import numpy as np

def sample_median(n, P):  

   return np.median( np.random.choice ( np.arange (1, len(P) + 1 ), n, p = P ) )

print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))

print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))

print(sample_median(5, [0.3,0.7])

print(sample_median(5, [0.3,0.7])

Explanation:

  • Bring in the numpy library to use the median function provided by the numpy library.
  • Define the sample_median function that takes in 2 parameters and returns the median with the help of built-in random, choice and arrange functions.
  • Call the sample_median function by providing some values to test and then display the results.    

Output:

4.5

4.0

2.0

1.0

7 0
2 years ago
A furniture manufacturer wants to find a more environmentally friendly way to make its products. A data analyst helps solve this
Alecsey [184]
The answer has to be true because everything makes sense
4 0
2 years ago
Salesforce organizes your data into: A. Objects and records, like tabs and rows on a spreadsheet. B. Objects and fields, like co
pshichka [43]

Salesforce organizes your data into option A. Objects and records, like tabs and rows on a spreadsheet.

<h3>How does Salesforce organize data?</h3>

Salesforce is known to be a tool that helps one to put together their your into objects and records and it is said to have standard objects that has been set up and ready for use.

Hence, Salesforce organizes your data into option A. Objects and records, like tabs and rows on a spreadsheet.

Learn more about Salesforce from

brainly.com/question/7452075

#SPJ1

7 0
2 years ago
Other questions:
  • What should the timing of transition slides be per minute?
    9·2 answers
  • A multiplicative inverse of 3 modulo 5 is any integer a such that 3 a ≡ 1 (mod 5) , hence for some a ∈ Z5 .
    12·1 answer
  • Are headphones considered a computer? Why or why not?
    13·2 answers
  • How to make logo black and white in paint?
    14·1 answer
  • 1. Given a sequential list with n numbers, represented in a one-dimensional array A) Write an algorithm to check if the list has
    14·1 answer
  • Which precaution should be taken when working inside computer systems??
    9·1 answer
  • IF YOU COULD CREATE A SOCIAL NETWORK:, what would it be like? What would make it so special about the others? (If you want you c
    9·1 answer
  • Arrange the steps involved in natural language generation.
    9·1 answer
  • How do science, mathematics, and technology each influence engineering
    9·2 answers
  • Your program has a loop. You want to exit the loop completely if the user guesses the correct word.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!