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
Suppose you send data to the 11111111 11111111 11111111 11111111 ip address on an ipv4 network. to which device(s) are you trans
xenn [34]
All devices on your network segment.
4 0
3 years ago
Describe the process of sorting the following list using the above algorithm:
Sindrei [870]

Answer:

A jewellery shop is having a sale.

A bracelet is reduced to £240.

a) What is the original price?

adadsadsadasdadad

5 0
3 years ago
Whats the best app for cheaters​
Sladkaya [172]

The for cheaters? Like what kind of Cheaters?

Explanation:

6 0
4 years ago
Using computer software, compare the 2016 year-to-date sales through February to the 2017 year-to-date sales through February fo
JulijaS [17]

Incomplete question. Here's a similar question found in the attachments.

<u>Answer:</u>

<u>General Motors Corp, Chrysler, Ford Motor Company, Toyota Motors sales USA Inc, Nissan North America Inc.</u>

<u>Explanation</u>:

By, using the MS Excel computer software, you would be able to compare the 2016 year-to-date sales through February 2017 year-to-date sales for each manufacturer.

Simply copy the data into the data cells of MS Excel, next use the =sum formula (which should have a minus sign; For example, =SUM (B5 - E5) would give you the difference between the 2016 sales and 2017 sales, only if sales for 2016 is found in column B row 5 and sales for 2017 in column E row 5).

Thus, the results obtained can further be evaluated to determine the manufacturers in the top five with increased sales.

3 0
4 years ago
Can you anyone please help me​
Yuliya22 [10]

Answer:

Option C I think

3 0
3 years ago
Other questions:
  • Assume you have just started a new job, have a car loan, and have a student loan. You have just received a cash gift of $1,000 f
    14·1 answer
  • Truncation is a keyword search technique that helps you find useful variations of a term or terms. You want to find books on the
    5·1 answer
  • Universal Containers is implementing a community of High-Volume Community users. Community users should be able to see records a
    12·1 answer
  • WHEN COPYING EXISTING SPREADSHEET DATA TO A WORD DOCUMENT YOU NEED TO SELECT?
    12·1 answer
  • The following is an example of what kind of loop?
    15·2 answers
  • Which search engine do you prefer? Why
    15·2 answers
  • What term is used to refer to the merging of government services with information technology?
    11·1 answer
  • 9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the
    11·1 answer
  • I really need this done Thank you!!
    6·1 answer
  • Which element is represented by the electron configuration in example B? Example B: 1s22s22p63s23p64s1 Aluminum Cesium Potassium
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!