In this example, we will write a program that finds the ASCII value of character input from user using Python code. To better understand this example, make sure you have knowledge of the following tutorials:-
ASCII stands for American Standard Code for Information Interchange. It is a numeric value given to different characters and symbols, for computers to store and manipulate.
Python Program to Find ASCII Value of Character
char = input("Enter a character: ")
print("The ASCII value of '" + char + "' is", ord(char))
The output of the above program is:-
Enter a character: e
The ASCII value of ‘e’ is 101
The input() function takes input from the user as a character. The built-in function ord converts a character to its ASCII value. ord() returns an integer representing the Unicode code point of the character when an argument is a Unicode object, or the value of the byte when the argument is an 8-bit string.