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
sergey [27]
3 years ago
7

A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never

odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.
Ex: If the input is:
bob
the output is:
bob is a palindrome
Ex: If the input is:
bobby
the output is:
bobby is not a palindrome
Computers and Technology
1 answer:
zubka84 [21]3 years ago
5 0

Answer:

string = input()

normal = ""

reverse = ""

for i in range(len(string)):

   if string[i].isalpha():

       normal += string[i].lower()

       reverse = string[i].lower() + reverse

if normal == reverse:

   print(string + " is a palindrome")

else:

   print(string + " is not a palindrome")

Explanation:

  • Loop up to the length of string.
  • Use an if statement to check if a certain character is an alphabet.
  • Check if both the normal and reverse strings are equal, then display that it is a palindrome.
You might be interested in
ORANGE COLORED SIGNS AND FLAGS MEAN THAT YOU MUST BE ALERT FOR:
Finger [1]
The best answer is B
Orange typically signalizes road work or construction.
4 0
4 years ago
Read 2 more answers
Backing up data on a computer means
aleksklad [387]

Answer: when you back data up you are copying it and then moving the copy to another storage device

6 0
3 years ago
Read 2 more answers
How to change screen resolution in windows 10?
pav-90 [236]
The easiest way is to hit the Windows icon on your keyboard, look for the Settings app, and look for screen resolution in the search bar.
7 0
3 years ago
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variable
levacccp [35]

Answer:

if (pH<7.0){

          neutral=0;

          base=0;

          acid=1;

      }

      else if (pH>7.0){

          neutral=0;

          base=1;

          acid=0;

      }

      else if (pH==7.0){

          neutral=1;

          base=0;

          acid=0;

      }

Explanation:

As required by the question, if and else statements have been used to test the value of the pH and assign the apropriate values to the variables neutral, base and acid.

The code snippet below can be used to prompt the user to enter values for pH

<em>import java.util.Scanner;</em>

<em>public class pHTest {</em>

<em>   public static void main(String[] args) {</em>

<em>      Scanner scr = new Scanner(System.in);</em>

<em>       System.out.println("Enter a value for the pH");</em>

<em>       int neutral, base, acid;</em>

<em>       double pH = scr.nextDouble();</em>

<em> if (pH<7.0){</em>

<em>           neutral=0;</em>

<em>           base=0;</em>

<em>           acid=1;</em>

<em>       }</em>

<em>       else if (pH>7.0){</em>

<em>           neutral=0;</em>

<em>           base=1;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>       else if (pH==7.0){</em>

<em>           neutral=1;</em>

<em>           base=0;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>} }</em>

4 0
4 years ago
Read 2 more answers
Surrendering to digital distractions can result in a disappointed
Alja [10]

Answer:

I would say true

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Sometimes we write similar letters to different people. For example, you might write to your parents to tell them about your cla
    9·1 answer
  • Which device should be used for enabling a host to communicate with another host on a different network?
    9·1 answer
  • Which naming scheme identifies the columns of a worksheet?
    12·1 answer
  • Given a variable n refers to a positive int value, use two additional variables, k and total to write a for loop to compute the
    13·1 answer
  • Suppose that a main method encounters the statement t3.join(); Suppose that thread t3's run() method has completed running. What
    15·1 answer
  • What is activated as necessary to support local eocs and to ensure that responders have the resources they need to conduct respo
    5·1 answer
  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Ab
    11·1 answer
  • On React
    13·2 answers
  • Hamilton is the best
    12·1 answer
  • What is a computer?write any four features of computer​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!