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
Which design element involves the act of lining up objects vertically or horizontally to give a sense of order?
Nadya [2.5K]

Answer:

HHJJTFCS

Explanation:

8 0
3 years ago
A personal identification number (PIN) that opens a certain lock consists of a sequence of 3 different digits from 0 through 9,
Elan Coil [88]

Answer:

<u>720</u> possible PIN can be generated.

Explanation:

To calculate different number of orders of digits to create password and PIN, we calculate permutation.

Permutation is a term that means the number of methods or ways in which different numbers, alphabets, characters and objects can arranged or organized. To calculate the permutation following formula will be used:

nPr = n!/(n-r)!

there P is permutation, n is number of digits that need to be organize, r is the size of subset (Number of digits a password contains)

So in question we need to calculate

P=?

where

n= 10   (0-9 means total 10 digits)

r= 3     (PIN Consist of three digits)

So by using formula

10P3 = 10!/(10-3)!

        =10!/7!

        = 10x9x8x7!/7!

        = 10x9x8

        = 720

7 0
3 years ago
Which of the following should you do if you are exhibiting your photographs?
Naddika [18.5K]

I would go with option a

hope that helped

3 0
3 years ago
While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
Sphinxa [80]
<span>To verify the version of HTML being run on any given page, check the DOCTYPE declaration at the head of the file. Use "inspect element" to view the page source; the DOCTYPE is generally in the header.</span>
5 0
3 years ago
Select the correct navigational path to create a combination chart. Select the chart. Click the Chart Tools tab. Select the data
nydimaria [60]

Answer:

format and design

Explanation:

8 0
3 years ago
Other questions:
  • How can you tell if a website is secure
    13·1 answer
  • In a bubble sort, you use a(n) ____ loop to make pair comparisons.
    5·1 answer
  • Gabriel needs to create a formula that does not change when it is copied to cell b2. which formula should he create?
    14·1 answer
  • What is the main feature of chat rooms?
    9·2 answers
  • Question #7
    10·2 answers
  • Give four advantages for ssd compared to hdd
    15·2 answers
  • List of rules for expert systems​
    6·1 answer
  • Circuit pruning occurs only before puberty.<br> O True<br> O False
    9·2 answers
  • A computer is defined by 4 specific criteri. Select all 4.*
    10·1 answer
  • What is the answer ????​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!