Write a Python program that prints the Unicode code values for a word entered by the user. Use the dictionary created in Exercise F.7.

What will be an ideal response?


```
# Returns Unicode equivalent of an English word

alphabet = {}

# 0x0041 = 'A' = 65 (decimal)
for i in range( 65, 91 ):

# key is letter
# value is hexadecimal value
alphabet[ chr( i ) ] = str( hex( i ) ).replace( "0x", "\u00" )

for i in range( 97, 123 ):
alphabet[ chr( i ) ] = str( hex( i ) ).replace( "0x", "\u00" )

# converts English letter to Unicode
def convertToUnicode( word ):

if alphabet.has_key( word ):
return alphabet[ word ]
else:
return "Not an English letter"

print "This program outputs the Unicode equivalent of a word."
word = raw_input( "Please enter a word: " )

for letter in word:
print convertToUnicode( letter ),

print
```
This program outputs the Unicode equivalent of an English word.
Please enter a word: Welcome
\u0057 \u0065 \u006c \u0063 \u006f \u006d \u0065

Computer Science & Information Technology

You might also like to view...

Which of the following is NOT one of the three spatial dimensions of 3-D?

A) Height B) Depth C) Length D) Width

Computer Science & Information Technology

When a new comment is inserted in a document, a(n) ________ displays

Fill in the blank(s) with correct word

Computer Science & Information Technology

Interesting fields are the fields that have at least 20% of resulting fields.

c B. False

Computer Science & Information Technology

A systems administrator wishes to improve security in a datacenter. The administrator wants to be alerted whenever a hard drive is removed from the server room. Which of the following security measures would BEST accomplish this?

A. RFID chips B. Security cameras C. Server and cabinet locks D. Mantrap E. Proximity reader

Computer Science & Information Technology