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
An alien from planet Tao has descended onto Earth.
DochEvi [55]

An alien from planet Tao has descended onto Earth. The Internet is a massive network of networks, a networking infrastructure. It connects millions of computers together globally, forming a network in which any computer can communicate with any other computer as long as they are both connected to the Internet.

Explanation:

  • A packet is the unit of data that is routed between an origin and a destination on the Internet or any other packet-switched network.
  • Network packets are small amounts of data passed over TCP/IP networks.
  • Latency measures the time it takes between your actions and the response between your computer, the internet, and everything in between.
  • An IP address is a label which is used to identify one or more devices on a computer network. It is comparable to a postal address.
  • The Domain Name System (DNS) is vital to the Internet, providing a mechanism for resolving host names into Internet Protocol addresses. Insecure underlying protocols and lack of authentication and integrity checking of the information within the DNS threaten the proper functionality of the DNS.
  • Transmission Control Protocol is a standard that defines how to establish and maintain a network conversation through which application programs can exchange data. TCP works with the Internet Protocol which defines how computers send packets of data to each other.

3 0
3 years ago
Please help with attached file
Paul [167]
Where is the attached file?
8 0
3 years ago
Read 2 more answers
If you ping a device, you are using the __________ protocol.
geniusboy [140]
Internet Control Messaging Protocol

If you use the -T switch, it'll be TCP
7 0
3 years ago
Read 2 more answers
How could social media have a negative impact if not used properly when seeking employment
castortr0y [4]
Before hiring someone, employers often check the social media pages of people applying for a job. If their social media account has content not up to the company's standards, they may not get the job. 
8 0
3 years ago
The faster the film (the higher the ISO), the more visible its grain. When you are using higher ISO, you are not just bringing g
NikAS [45]
I could not tell you
3 0
3 years ago
Read 2 more answers
Other questions:
  • What is a common method for testing a spot weld?
    13·1 answer
  • 22 If you are involved in a violation and you do not have insurance to comply with the __________________, your driver license a
    9·2 answers
  • How do governments correct for negative externalities?
    5·1 answer
  • The site is not allowing me to purchase the subscription. Please help?
    12·1 answer
  • What are the consequences of plagiarism?
    7·2 answers
  • Write a class called Date that represents a date consisting of a day, month, and year. A date object should have the following m
    10·1 answer
  • Instructions
    8·1 answer
  • (TCO B) The symbol shown as a three-sided box that is connected to the step it references by a dashed line is what?
    12·1 answer
  • Book information (overriding member methods) Given main() and a base Book class, define a derived class called Encyclopedia. Wit
    12·1 answer
  • A field value is currently not in any group. what happens when you try adding it to an existing group?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!