Question

Python Jupyter Notebook An acronym is a word formed by taking the first letters of the...

Python Jupyter Notebook

An acronym is a word formed by taking the first letters of the words in a phrase and making a word from them. For example, RAM is an acronym for "random access memory." Write a program that allows the user to type in a phrase and then outputs the acronym for that phrase. Note : The acronym should be all uppercase, even if the words in the phrase are not capitalized

### Complete the algorithm (Can be solved with just 3 line of code)
# (Can be resolved with just 1 line of code if not validation is added.)
def generate_acronym(phrase):
pass

# DO NOT MODITY Anything below
# (Your implematation must be able to use this with success.)
# Hint: The generate_acronym method should return the acronym
def main():
print(generate_acronym(input('Enter the phrase >> ')))

main()

Homework Answers

Answer #1

Code:

def generate_acronym(phrase):
phrase_words=phrase.split()
#Here we split the phrase into words
return "".join(pword[0] for pword in phrase_words).upper()
#then we join the first letter of the each word and convert it into upper case

def main():
print(generate_acronym(input('Enter the phrase >> ')))
#Here we call the generate_acronym function
main()
#Here we call the main method

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...