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]
3 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]3 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
What are the two options for adding a new slide into presentations?
nirvana33 [79]
The first being Ctrl+M and the second being clicking the <span>top half of the New Slide button</span>
5 0
3 years ago
Where does the report footer section appear?
natka813 [3]

The report footer section appears at the bottom of the last page. The correct option is b.

<h3>What is a report footer section?</h3>

The report footer is that contain the report items. It is placed in the last page or the bottom of the report border. It is present only one time exactly at the last page.

Thus, the correct option is b, at the bottom of the last page.

Learn more about report footer section

brainly.com/question/13261774

#SPJ1

3 0
2 years ago
Cuáles son las redes sociales que más utilizas tú y tu familia. Describe su utilidad.
Ymorist [56]

Answer:

Facebok

Explanation:

we are able to see everthing other people do and are able to limit what are kids do

6 0
3 years ago
What is the output of
Vaselesa [24]
0
1
2
3
4

Those are the outputs
6 0
3 years ago
Read 2 more answers
When passing a non-const argument to a const function, the const_cast operator should be used to cast away the "const-ness" of t
Nataly_w [17]
False i think I’m not sure
4 0
3 years ago
Other questions:
  • When saving a file, you must provide a valid file name that adheres to specific rules, referred to as _______________.
    5·1 answer
  • While building a high-end gaming system, you are attempting to install the EVGA GeForce GTX 1080 graphics card and discover ther
    9·1 answer
  • The control programs managing computer hardware and software perform the _________ function to control and prioritize tasks perf
    8·1 answer
  • Write the definition of a method named countPos that receives a reference to a Scanner object associated with a stream of input
    13·1 answer
  • Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scor
    7·1 answer
  • Write a Python function prime_generator that takes as argument positive integers s and e (where s
    11·1 answer
  • Write a program that will open a file named thisFile.txt and write every other line into the file thatFile.txt. Assume the input
    7·1 answer
  • PLZ HELP!!!
    8·1 answer
  • What is htc one mseven​
    11·1 answer
  • Develop a command sequence would you use to alter the amount of space between the text in a text box and the text box border?.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!