top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Morse Code Translator In Python

Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. It is named for Samuel F. B. Morse, an inventor of the telegraph. The algorithm is very simple. Every character in the English language is substituted by a series of dots and dashes or sometimes just singular dot or dash and vice versa as described below :




def convert_morse(code):
    
    code = code.replace("a", ".-")
    code = code.replace("b", "-...")
    code = code.replace("c", "-.-.")
    code = code.replace("d", "-..")
    code = code.replace("e", ".")
    code = code.replace("f", "..-.")
    code = code.replace("g", "--.")
    code = code.replace("h", "....")
    code = code.replace("i", "..")
    code = code.replace("j", ".---")
    code = code.replace("k", "-.-")
    code = code.replace("l", ".-..")
    code = code.replace("m", "--")
    code = code.replace("n", "-.")
    code = code.replace("o", "---")
    code = code.replace("p", ".--.")
    code = code.replace("q", "--.-")
    code = code.replace("r", ".-.")
    code = code.replace("s", "...")
    code = code.replace("t", "-")
    code = code.replace("u", "..-")
    code = code.replace("v", "...-")
    code = code.replace("w", ".--")
    code = code.replace("x", "-..-")
    code = code.replace("y", "-.--")
    code = code.replace("z", "--..")
    
    code = code.replace("1", ".----")
    code = code.replace("2", "..---")
    code = code.replace("3", "...--")
    code = code.replace("4", "....-")
    code = code.replace("5", ".....")
    code = code.replace("6", "-....")
    code = code.replace("7", "--...")
    code = code.replace("8", "---..")
    code = code.replace("9", "----.")
    code = code.replace("0", "-----")

    code = code.replace(",", "--..--")
    code = code.replace(".", ".-.-.")
    code = code.replace("?", "..--..")
    code = code.replace("/", "-..-.")
    code = code.replace("-", "-....-")
    code = code.replace("(", "-.--.")
    code = code.replace(")", "-.--.-")

    return code

covert_morse has a string argument and split each character to replace it bu their corresponding one to construct the morse code.


msg = input("Enter any message: ") print(f"Initial code :{msg}") morse = convert_morse(msg) print(f"Morse code: {morse}")


 
 
 

1 Comment


musicq821
musicq821
Dec 26, 2022

Hi. You do manage to make glorious articles. I have found many of them to be of practical use to me. It seems to me that if you had a social network or YouTube channel, you would find your audience for sure, and many times more of what you have now. So then maybe it makes sense to try to get a channel on YouTube? If you don't understand anything about it, it's not a problem at all, because there are these guys www.movavi.com/learning-portal/best-mp4-to-mp3-converters.html. They have a big store of software for working with video, and they also produce tutorials on their channel and write useful articles, so it won't take you more than a couple of days to learn…

Like

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