157k views
3 votes
Write a program that receives an character and displays its Unicode. Here is a sample run: Enter an character: E The Unicode for the character E is 69

1 Answer

1 vote

Answer:

The program written in Python programming language is as follows;

Comments are not used because the code is self explanatory; However, see explanation section for line by line explanation

char = input("Enter a character: ")

print("The Unicode for the character " + char[0] + " is", ord(char[0]))

Step-by-step explanation:

Line 1 of the program prompts the user for an input of a character

char = input("Enter a character: ")

The next line prints the Unicode equivalent of the input text. However, if the input length is more than 1, the program will only consider the first character and discard the rest

print("The Unicode for the character " + char[0] + " is", ord(char[0]))

User Paul Santosh
by
5.6k points