top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Acronym Generator in Python

In this tutorial, you'll learn to create a simple Acronym Generator using Python.


What is an acronym?

An acronym is a word formed from abbreviating a phrase by combining certain letters of the phrase (often the first letter of each word) into a single word.


Note: Prepositions like 'of' are usually not considered for acronyms.


How an acronym generator works?

An Acronym Generator will take a String as an input and for the output it will return the initials of all the words in the String.




 

How to create acronym using python?


Step 1: Get the user input.

First of all, we need to get the phrase from the user.

We can do it easily with the use of input() method, the user input will be stored in an input_user variable.


#adding the user input
input_user = input("Please Type a phrase: ")

Step 2: Ignore prepositions.

In the second step, we have to ignore ‘of’ from the user input .

#ignore 'of'
clean_input = (input_user.replace('of', ''))

Step 3: Create a list of words.

Next step, we need to extract the words from the clean_input string and to store them as a list in phrase variable.

# Split words
phrase = clean_input.split()

Step 4: Code the acronym generator's logic.

Then, we initilize an empty variable acronym .

acronym = ""

we are going to extract the first letter of every word stored in phrase using slicing operator and adding it to acronym variable than capitalizing it with the use of upper() function. .

for w in phrase:
    acronym = acronym + w[0].upper()

Finally, Let's add a print statement

print('The acronyme of ' + input_user + ' is '+ acronym)

Step 5: Run the code

let's try running our Code!




 

Source Code

Thank you so much for reading! I hope you found this project useful.

You can find the complete source code of this project here ==> SourceCode


1 comment

Recent Posts

See All

COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page