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
AfilCa [17]
3 years ago
6

Write a Python program which asks a user for a word and performs letters manipulation. If the word is empty, the program should

print the message empty! Otherwise, if the word has between one and four letters (inclusive), the program should print the reversed word. Otherwise, the program should print a word made of the first two and the last two letters of the original word. Your program should match the sample output as displayed below.
Sample Output
Enter a word:
Result: empty!

Enter a word: bio
Result: oib

Enter a word: memory
Result: mery
Computers and Technology
1 answer:
never [62]3 years ago
8 0

Answer:

The program is as follows:

word = input("Enter a word: ")

if word:

   if len(word) <= 4:

       word = word[::-1]

   else:

       word = word[0]+word[1]+word[-2]+word[-1]

   print(word)

else:

   print('empty!')

Explanation:

This gets input for word from the user

word = input("Enter a word: ")

If input is not empty

if word:

This checks if the length is less than or equal to 4 characters

   if len(word) <= 4:

If yes, this reverses the word

       word = word[::-1]

If otherwise,

   else:

This gets the first, second, second to last two characters

       word = word[0]+word[1]+word[-2]+word[-1]

Print the new string

   print(word)

Print empty, if input is empty

<em>else: </em>

<em>    print('empty!')</em>

You might be interested in
To secure the company website, the webmaster suggests that the company purchase a secure certificate to encrypt all communicatio
iVinArrow [24]

Answer: Software

Explanation:

Security certificate is defined as the assurance that maintain authenticity and intactness of a website or different sites.It is present in small sized data filed that establishes encryption and validation through verification of owner's identity.

  • As per the suggestion of Webmaster, who takes care of web-pages and web-servers , security certificate should be purchased to verify the transmission of message with encryption.
  • Certificate in this case will be acting as software for providing security and operations to the websites.

4 0
3 years ago
How does theatre compare with movies or television? What makes it similar to movies and television? What makes it different?
givi [52]

Answer:

you cant mess up in theatre but you can redo scences in movies, thay both have acting in them

Explanation:

im a theatre person

3 0
3 years ago
Using the spreadsheet below, which formula can be used to determine Albert's hourly wage?
algol13

Answer:

It will be average (B2:C2)

as it will select all the data between B2 and C2

7 0
3 years ago
Read 2 more answers
Drag each tile to the correct box.
garri49 [273]
I think select the video insert select the movie option under illustrations resize the video player then select the insert tab i’m not 100 percent sure tho
8 0
3 years ago
Read 2 more answers
Why do we need to update database regularly
sergiy2304 [10]
To protect from attackers gaining access by sitting on a certain configuration too long. 
7 0
3 years ago
Other questions:
  • Using a pin or password in addition to tpm is an example of what type of authentication?
    13·1 answer
  • . It is essential for a relay energized by alternating current to have A. many turns of small wire. B. a laminated core and a sh
    8·1 answer
  • When you take a multiple-choice test, you are relying on ________, a means of retrieving information out of your long-term memor
    8·1 answer
  • Universal Containers has a sales team focused on renewals. They will use many of the same Opportunity fields as other teams, but
    13·1 answer
  • Complete the following statement: Sustainability is: Choose all that apply.This task contains the radio buttons and checkboxes f
    10·1 answer
  • Write the method addItemToStock to add an item into the grocery stock array. The method will: • Insert the item with itemName ad
    12·1 answer
  • Difrent between computer and computer system​
    9·1 answer
  • Which of the following describes the line spacing feature? Select all that apply. adds space between words adds space between li
    8·1 answer
  • What makes you normally visit the site-graphics, layout, or content? Why?​
    8·2 answers
  • To create a program in Scratch, you need to think systematically about the order of steps. This is known as
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!