Python Program to Print ASCII Value of a Character

How to print ascii value of a character?

ord() is an inbuilt function used to print an ascii value in python. It coverts given string of length 1 into an integer representing the unicode of the character.

For example, ord(‘a’) returns the integer 97.

ASCII stands for American Standard Code for Information Interchange.

Each character available in the system has a specific ascii value which the computer uses internally for character manipulation puuposes.

Python program to print ASCII value of a character

Write a python program to print ascii value of a character.

# accept character from user
ch = input("Enter any character: ")

# store a character
ch = 'a'

# print the ASCII value of character in variable ch
print("The ASCII value of  character '" + ch + "' is", ord(ch))


The ASCII value of character 'a' is 97 

There are so many different characters in the world other than alphabets in english.

Ascii only encodes 128 characters so one universal mechanism is needed to handle all the characters.

Unicode is an encoding technique that provides a unique number to a character. This removes the limitaion of 128 characters only. The current Unicode has more than 100,000 characters from hundreds of script.

Unicode is unversally accepted and used all over the code to handle non native characters.