Did You Know?
The NATO Phonetic Alphabet is the most widely used spelling alphabet. A spelling alphabet (aka radio alphabet, or telephone alphabet) is a set of words used to stand for the letters of an alphabet in oral communication. Each word in the spelling alphabet typically replaces the name of the letter with which it starts. It is used to spell out words when speaking to someone not able to see the speaker, or when the audio channel is not clear.
Nowadays people may use the NATO Phonetic alphabet when they have to spell their name or their postcode over the phone.
For instance, the name Smith would spell Sierra – Mike – India – Tango – Hotel.
Challenge
This challenge consists of writing a computer program that will ask the end-user to enter their lastname. The program will output their lastname using the NATO Phonetic Alphabet.
To complete this challenge you may want to investigate the use of a dictionary in Python.
Learning Objectives
By completing this challenge we are going to learn about Python dictionaries.
In Python, a dictionary consists of pairs (called items) of keys and their corresponding values.
Python dictionaries are also known as associative arrays or hash tables. The general syntax of a dictionary is as follows:
myDictionary = {"Red": "#FF0000", "Green": "#00FF00", "Blue": "#0000FF"} print("The colour code for Green is:") print(myDictionary["Green"])
NATO Phonetic Alphabet
Letter | Code |
A | Alfa |
B | Bravo |
C | Charlie |
D | Delta |
E | Echo |
F | Foxtrot |
G | Golf |
H | Hotel |
I | India |
J | Juliett |
K | Kilo |
L | Lima |
M | Mike |
N | November |
O | Oscar |
P | Papa |
Q | Quebec |
R | Romeo |
S | Sierra |
T | Tango |
U | Uniform |
V | Victor |
W | Whiskey |
X | X-ray |
Y | Yankee |
Z | Zulu |
– | Dash |
Let’s get coding…
Extension
You can use the same approach to create a Morse Code Encoder!
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area