ASCII abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication.
Just to understand in simple language, it is a value given to different characters and symbols. For example, the ASCII value of alphabet A
is 65.
The task here is to print the ASCII value of the provided character.
Python provides two inbuilt methods to get ASCII value from character and character from ASCII value.
ord(c) | For a given Unicode character(provided as String), return an integer representing the Unicode code point of that character. |
chr(i) | Return the string representing a character whose Unicode code point is the integer i. For example, chr(65) returns the string ‘A’. |
# Character for which ASCII value to be retrieved character = 'A' print('ASCII value of character is ',ord(character))
Output
ASCII value of character is 65
Python program to get character value from ASCII value
#ASCII value for which character to be retrieved ascii = 65 print('ASCII value of ASCII value is ',chr(ascii))
Output
ASCII value of ASCII value is A