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
List of steps to apply bold and italic formatting to a word​
ch4aika [34]
To make text bold, select and highlight the text first. Then hold down Ctrl (the control key) on the keyboard and press B on the keyboard. To make text italic, select and highlight the text first. Then hold down Ctrl (the control key) on the keyboard and then press the I on the keyboard
5 0
4 years ago
Read 2 more answers
Which of the following is not a good use of a spreadsheet?
Ivanshal [37]
I’d say business letter
4 0
3 years ago
Which of the following can you do under the fair use exceptions?
anzhelika [568]
What fair use exceptions are you talking about? There are thousands on fair use exceptions.
8 0
3 years ago
Dust buildup inside a desktop PC case can be managed effectively by ____.
antoniya [11.8K]
Frequent cleaning with an air duster can would do the job
6 0
3 years ago
Read 2 more answers
Back injuries are very common in humans and are often caused by lifting objects with the legs straight while leaning over; also
saveliy_v [14]

Answer:

Back injuries are some of the most common injuries that occur when handling heavy objects, for example, when working in truck loading and unloading jobs, or lifting weights in a gym.

This type of injury is mainly caused by incorrect posture or body position when handling these weights. In essence, it is recommended that the back remain rigid and upright to avoid pressure on the lumbar zone and the cervical discs, transferring the center of force towards the legs (which have a capacity to exert much greater force than the mid-torso and back area). low).

In this way, the torque or upward pushing force that lifts the manipulated weights arises from the hamstrings and quadriceps, rather than directly out of the waist area. This prevents injuries such as herniated disc or low back pain, which are very painful and difficult to treat.

8 0
3 years ago
Other questions:
  • When santo is formatting the text in his wordart text box, he discovers that by default the text box is formatted with _______ t
    11·1 answer
  • What is Least effective at preventing a computer virus
    10·1 answer
  • Two advantages of Internet are ?​
    7·2 answers
  • Does anyone know any nitro type hack??
    13·2 answers
  • Será que me podrían ayudar pasandome los códigos por favor
    13·1 answer
  • The compound known as butylated hydroxytoluene, abbreviated as BHT, contains carbon, hydrogen, and oxygen. A 1.501 g sample of B
    11·1 answer
  • Kahoot plzkahoot plzkahoot plz
    11·1 answer
  • Def shared_motif(dna_list):
    13·1 answer
  • Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M
    5·1 answer
  • help i was building my pc and i pushed the cpu into the socket really hard until there was an audible crack and it went into the
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!