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
For the following array x [10] = { 45, 20, 50, 30, 80, 10, 60, 70, 40, 90} show the contents of x after the function call split
Valentin [98]

Answer:

The array index by using split function.

45 20 50 30 80 10 60 70 40 90

45 20 40 30 80 10 60 70 50 90

45 20 40 30 10 80 60 70 50 90

10 20 40 30 45 80 60 70 50 90

Explanation:

In the following statement, there is an integer array type variable x and its index value is 10 that means it contains only 10 numeric values and then, they set split function which split the array and the split function is the built-in function which is used to separate the string or an array. So, the array is split into the following parts.

5 0
3 years ago
Assume the name of your data frame is flavors_df. What code chunk lets you review the structure of the data frame?
Svetlanka [38]

Assuming the name of your data frame is flavors_df, the code chunk which will allow review of the structure of the data frame is colnames(flavors_df).

<h3>What is Code chunk?</h3>

This is referred to a a runable piece of R code and helps to reduce incidents of mismatch pertaining to the commentary in a paper and the results being discussed.

In the case of a data frame which is flavors_df, the appropriate code chunk is colnames(flavors_df) which allow for extensive review of the item with the barest minimal error which is why it was chosen as the most appropriate choice.

Read more about Code chunk here brainly.com/question/25525005

#SPJ1

4 0
1 year ago
Clicking the _____ box completes an entry. cancel formula enter tab
DaniilM [7]
Enter tab would complete an entry. I hope that helped ya! 
4 0
3 years ago
A technician wants to limit access to a group of folders and is using Group Policy to prevent the users in the sales department
Mashcka [7]

Answer:

d. The technician should be setting NTFS permissions instead of using Group Policy.

Explanation:

NTFS (New Technology File System) permissions run on drives formatted with NTFS.Under NTFS permissions, individual users are granted permission at the Windows logon and so in this way local users and network users are affected, affecting each user from wherever he may be connecting from. In the example above using NTFS permissions would solve the problem of file system among departments .

4 0
2 years ago
Write a program in python to test if given number is prime or not.
Paraphin [41]

Answer:

Answer:

def main():

num = int(input("Input a number to check for prime: "))

if num > 1:

 for i in range(2,num):

  if (num % i) == 0:

   print("%d is not a prime number" % num)

   break

  else:

   print("%d is a prime number" % num)

   break

else:

 print("%d is not a prime number" % num)

 

if __name__ == "__main__":

main()

Explanation:

Solution retrieved from programiz.com.

Note, this program uses the idea of the Sieve of Eratosthenes to validate the input number by using the modulo operator to determine primeness.

The program will output to the user if the number input is indeed prime or not.

Cheers.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the primary criticism against a national identification system based on biometric data?
    13·1 answer
  • major m,ajorrr points helpppppppppppppppppppppppppppi have a question i hit a few buttons and now my computer is saying everythi
    11·2 answers
  • What can web designers use to control the individual web page layouts for all of the pages on a website?
    7·1 answer
  • ​this is another name for the wireless configuration in which a central wireless device is used to serve all wireless clients.
    13·1 answer
  • The level of competition is an important factor for many people when selecting a physical activity.
    7·2 answers
  • What is an example of a memo
    9·1 answer
  • LeonRoyal15 if anyone plays fortnite
    10·2 answers
  • Read two numbers from user input. Then, print the sum of those numbers. Hint - Copy/paste the following code, then just type cod
    9·1 answer
  • This feature automatically creates tables of contents.
    5·1 answer
  • Basics of visual basic
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!