Hour of Python - Coding Challenge 10 | Morse Code

preview_player
Показать описание
Enroll for exercises, tutorials, courses, and projects...

Enroll in Learn Python™ course

==================================================
Connect With Me!

Snapchat ► Rafeh1
Рекомендации по теме
Комментарии
Автор

Morse code was a telecommunication method invented in the early 1800s to transmit natural language over electrical wires. Fast, long-distance communication before telephones. No cryptography envolved and is still in use today.

flybyguy
Автор

Thanks, I like your coding style. It's very slow and deliberate! Good job!

ProgramWithErik
Автор

You missied something really important. Your Morse code is not readable since letters in Morse code are represented as various symbols and you didn’t separate them. So basically it’s just a mess of “.” And “-“.

What you also should maybe try do with this type of videos is to code the reverse version of the function.

sashamoroz
Автор

def morsify(word):
output=''
for i in range(0, len(word)):
output+=morse_code[word[i]]
return output

gorkemcelebiler
Автор

"I am going fast" lol about 60% of the video is him not talking about Python or the challenge.

bendavis
Автор

I have a question:

Why learn python? What can be made with it, or what's the most practical thing to make with it? Data crawling? Software creation? Games?

How can I strengthen my skills in Python?

apathyghoul
Автор

I really liked your Now I found a "hero" to follow in my studies!!!! thank you so much !

fredpurri
Автор

9:40 it takes a lot of time for me to do basic things too. And a lot of times i'm being mislead by my assumptions on how should i do things, so the code would work. Thank you very much!

Eeatch
Автор

Okay, it took awhile, but that's because I had to reconstruct the morse_code dictionary. I purposely lowercased trinket just to be thorough. Also, you'll notice I used something called and end parameter. In Python, strings and integers are typically output on a new line, so the end parameter is the \n escape sequence by default. By leaving the end parameter, blank, we can have the morse code letters on the same line, but that's not all. the blank left in the end parameter also allows you to have any number, letter or a space in between.

string = "AESTHETIC"
for letter in string:
print(letter, end=" ")

So say you took the string AESTHETIC, right? We want to put a space between the letters, so we use a For Loop that takes each letter, and prints it out. Since end=" ", the output would be "A E S T H E T I C".

Anyways, here's my solutions:

morse_code = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q": "--.-",
"R": ".-.",
"S": "...",
"T": "-",
"U": "..-",
"V": "...-",
"W": ".--",
"X": "-..-",
"Y": "-.--",
"Z": "--.."
}

# function with print
def morsify(string):
for letter in string:
print(morse_code[letter.upper()], end="")
return " " + string.upper()

print(morsify("trinket"))

# without the print
def morsify(string):
string_morse = ''
for letter in string:
string_morse = string_morse + morse_code[letter.upper()]
return string_morse + " " + string.upper()

print(morsify("trinket"))

stellarestuary
Автор

def morsify(string):
return ''.join([morse_code[letter] for letter in string])

MrHidden
Автор

Nice video, that was a little tougher than the last few. I did mine by appending to a list

from morse import morse_code

def morsify(string):
# Add code here that returns the answer
ans = []
for char in string:
ans.append(morse_code[char])

return "".join(ans)

print morsify("TRINKET")
print morsify("Z")
print morsify("A")

denismurphy
Автор

each letter in morse need to be separated from the other, to be usable.
So you need to fill in a blank space in, like : "final_string + ' ' + morse_code[letter]"

Pramix
Автор

Don’t confuse Morse Code with encryption. It encodes a message in a digital way.

Voke
Автор

That was my first program I did ever!It took me 6mins

joenickson
Автор

Where do I go to import the morse code? How do I import the dictionaries? Im just running a python shell

williambuchanan
Автор

I want to have accent like you dude.Awesome content and your style is unique. Thank you so much god for sending him here for us.😍

nirajacharya
Автор

Can I somehow append input function to print morsify ("...." )to collect the word or phrase to be translated?
Like: using input "Enter a phrase for translation" and if i print the function the phrase gets translated to morse code.
Thanks a lot

martinprager
Автор

thats an awfully long function, just do this


def Morse(input):
return ' '.join([morse[x] for x in input])

SintaxErorr
Автор

if I store the whole this in a single string then how will I decrypt it later? I think adding them in a List would have been a better idea!!

sohambiswas
Автор

can you please do a learning Java series. I just completed the learning python one and I would love to learn Java now.

justg
join shbcf.ru