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
frozen [14]
2 years ago
12

Your task is to build a palindrome from an input string.A palindrome is a word that readsthe same backward or forward. Your code

will take the first 5 characters of the user input, and create a 9-character palindrome from it.Words shorter than 5 characters will result in a runtime error when you run your code. This is acceptablefor this exercise, however you already know how to validate user input with an IF statement.Some examplesof input words and the resulting palindromes:
Computers and Technology
1 answer:
White raven [17]2 years ago
7 0

Answer:

The program in Python is as follows:

word = input("Word: ")

if len(word) < 5:

   print("At least 5 characters")

else:

   pal = word[0:5]

   word = word[0:4]

   word = word[::-1]

   pal+=word

   print(pal)

Explanation:

This gets the word from the user

word = input("Word: ")

This checks if the length of the word is less than 5.

if len(word) < 5:

If yes, this tells the user that at least 5 characters is needed

   print("At least 5 characters")

If otherwise

else:

This extracts the first 5 characters of the word into variable named pal

   pal = word[0:5]

This extracts the first 5 characters of the word into variable named word

   word = word[0:4]

This reverses variable word

   word = word[::-1]

This concatenates pal and word

   pal+=word

This prints the generated palindrome

   print(pal)

You might be interested in
Which of the following is the best example of market censorship
Papessa [141]
To bleep it out! hopefully this helped
4 0
3 years ago
Read 2 more answers
A search engine finds bugs and system failures in your computer.<br><br> True or False?
scZoUnD [109]
It is false search engine are used for searching for something
6 0
2 years ago
Read 2 more answers
Find the propagation delay for a signal traversing the in a metropolitan area through 200 km, at the speed of light in cable (2.
Ede4ka [16]

Answer:

t= 8.7*10⁻⁴ sec.

Explanation:

If the signal were able to traverse this distance at an infinite speed, the propagation delay would be zero.

As this is not possible, (the maximum speed of interactions in the universe is equal to the speed of light), there will be a finite propagation delay.

Assuming that the signal propagates at a constant speed, which is equal to 2.3*10⁸ m/s (due to the characteristics of the cable, it is not the same as if it were propagating in vaccum, at 3.0*10⁸ m/s), the time taken to the signal to traverse the 200 km, which is equal to the propagation delay, can be found applying the average velocity definition:

v = \frac{(xf-xo)}{(t-to)}

If we choose x₀ = 0 and t₀ =0, and replace v= 2.3*10⁸ m/s, and xf=2*10⁵ m, we can solve for t:

t =\frac{xf}{v}  =\frac{2e5 m}{2.3e8 m/s} =8.7e-4 sec.

⇒ t = 8.7*10⁻⁴ sec.

4 0
3 years ago
Which of the following is a feature that is in the Excel program and NOT in Word? (Select all that apply.)
nikklg [1K]
I believe it is workbooks.
5 0
2 years ago
Write a subclass named 'ReadWrite' with the following additional behavior: Any necessary constructors. a method named 'setVal' t
nataly862011 [7]

Answer:

Java Class given below

Explanation:

class ReadOnly

{

protected int val;

public ReadOnly(int arg)

{

val = arg;

}

public int getVal()

{

return val;

}

}

class ReadWrite extends ReadOnly

{

private boolean dirty;

public ReadWrite(int arg)

{

super(arg);

dirty = false;

}

public void setVal(int arg)

{

val = arg;

dirty = true;

}

public boolean isDirty()

{

return dirty;

}

}

6 0
3 years ago
Other questions:
  • What is the formula for calculating the average of cells<br> C2 through C30?
    15·1 answer
  • Write a main method that prompts the user for an integer between 1 &amp; 10 (inclusive). If the user enters an invalid number, p
    10·1 answer
  • Diane wants to maintain a record of grades scored in the fifth, sixth, and seventh grades. She enters her grades and the total p
    13·1 answer
  • People with healthy media diets:
    12·1 answer
  • Which element in the PowerPoint application is not available in the Microsoft Word application?
    12·2 answers
  • Plz help me of this answer<br><br><br>language:python​
    7·2 answers
  • In order to do a binary search on an array Group of answer choices you must first do a sequential search to be sure the element
    5·1 answer
  • A two-dimensional array of characters can contain Group of answer choices
    11·1 answer
  • 9.A major step before taking print of the document is (3 points)
    14·1 answer
  • What are the five generations of computers?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!