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