Hello everyone, This is Tanmay Gupta from @Tanmays_corner . Today I made a Morse code translator using which we can translate any English phrase to Morse code. I used only stings no library and modules were used. I wrote the program in Replit. It is a free website on which we can write and publish our programs in any programming language.
To make this translator, I defined Morse code as strings for each alphabet, number and symbols. Then I took the user input for the phrase that you want to convert to Morse code. And replaced each letter, number and symbols with the Morse code string. And then printed it.
The international Morse code:
https://upload.wikimedia.org/wikipedi...
The alphabet string:
#alphabets
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 = ' --•• '
The string for numbers:
#numbers
i = ' •---- '
ii = ' ••--- '
iii = ' •••-- '
iv = ' ••••- '
v = ' ••••• '
vi = ' -•••• '
vii = ' --••• '
viii = ' ---•• '
ix = ' ----• '
x = ' ----- '
The string for symbols:
#symbols
space = ' / '
qm = ' ••--•• '
comma = ' -••- '
d_i_c = ' •-••-• '
colon = ' ---••• '
lb = ' -•--• '
rb = ' -•--•-'
em = ' •-•- '
atr = ' •--•-•'
ands = ' •-••• '
eq = ' ••• '
plus = '•-•-•'
s_i_c = ' •----• '
And replacement codes:
ui1 = ui1.replace(' ',space)
ui1 = ui1.replace('?',qm)
ui1 = ui1.replace(',',comma)
ui1 = ui1.replace('"',d_i_c)
ui1 = ui1.replace(':',colon)
ui1 = ui1.replace('(',lb)
ui1 = ui1.replace(')',rb)
ui1 = ui1.replace('!',em)
ui1 = ui1.replace('@',atr)
ui1 = ui1.replace('&',ands)
ui1 = ui1.replace('=',eq)
ui1 = ui1.replace('+',plus)
ui1 = ui1.replace('\'',s_i_c)
ui1 = ui1.replace('A',A)
ui1 = ui1.replace('B',B)
ui1 = ui1.replace('C',C)
ui1 = ui1.replace('D',D)
ui1 = ui1.replace('E',E)
ui1 = ui1.replace('F',F)
ui1 = ui1.replace('G',G)
ui1 = ui1.replace('H',H)
ui1 = ui1.replace('I',I)
ui1 = ui1.replace('J',J)
ui1 = ui1.replace('K',K)
ui1 = ui1.replace('L',L)
ui1 = ui1.replace('M',M)
ui1 = ui1.replace('N',N)
ui1 = ui1.replace('O',O)
ui1 = ui1.replace('P',P)
ui1 = ui1.replace('Q',Q)
ui1 = ui1.replace('R',R)
ui1 = ui1.replace('S',S)
ui1 = ui1.replace('T',T)
ui1 = ui1.replace('U',U)
ui1 = ui1.replace('V',V)
ui1 = ui1.replace('W',W)
ui1 = ui1.replace('X',X)
ui1 = ui1.replace('Y',Y)
ui1 = ui1.replace('Z',Z)
ui1 = ui1.replace('1',i)
ui1 = ui1.replace('2',ii)
ui1 = ui1.replace('3',iii)
ui1 = ui1.replace('4',iv)
ui1 = ui1.replace('5',v)
ui1 = ui1.replace('6',vi)
ui1 = ui1.replace('7',vii)
ui1 = ui1.replace('8',viii)
ui1 = ui1.replace('9',ix)
ui1 = ui1.replace('0',x)
The link to the code:
https://replit.com/@TanmayGupta3/moar...
My replit account:
https://replit.com/@TanmayGupta3
Please tell me our results in the comment. And suggest me some programs. Thanks for watching
Auf dieser Seite können Sie das Online-Video MAKING A MORSE CODE CONVERTER IN PYTHON USING STRINGS ONLY. WITHOUT ANY LIBRARY OR MODULE. mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Tanmay's Corner 20 November 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 31 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!