In this Python lesson, we will practice how to write a program that finds the ASCII value of a character. ASCII is an acronym for American Standard Code for Information Interchange. It is a computer-based numeric values that are given to character and symbol in computer programing for storage purpose. Below is the ASCII truth table.
Example: Find the ASCII Value of the Character
# request a character from user
cha = str(input('Enter any character: '))
print('ASCII value of {0} = {1}'.format(cha,ord(cha)))
Output
Enter any character: a
ASCII value of a = 97
In the above program, we used the ord() built-in function to convert a character to its corresponding ASCII value. What it returns is the Unicode code point of that specific character.
Unicode is an encoding technique that provides a unique number to a character. While ASCII only encodes 128 characters, Unicode has more than 100,000 characters from hundreds of scripts.