Python Program to Find ASCII Value of a Character

In this program, we will discuss how to find the ASCII value of a character using the Python programming language.

What is ASCII value?

It stands for American Standard Code for Information Interchange which is a numerical representation of characters in computers ranging from 0 to 127.

A character variable holds ASCII value rather than that character itself in Python programming language.

For example, Character ‘A’ is represented by 65.

What this means is that, if you assign ‘A’ to a character variable, 65 is stored in that variable rather than ‘A’ itself.

Python Programming Code to find the ASCII value of a character

In this program, we will ask for a character from the user and then print its ASCII value using the ord() in-build function.

Code:-

c = input("Enter a Character: ")

print("The ASCII value of character " + c + " is", ord(c)) 

Output:-

Enter a Character: g
The ASCII value of character g is 103
Enter a Character: Y
The ASCII value of character Y is 89

You can learn about many other Python Programs Here.

Best Books for learning Python with Data Structure, Algorithms, Machine learning and Data Science.

The following two tabs change content below.

Amit Rawat

Founder and Developer at SpiderLabWeb
I love to work on new projects and also work on my ideas. My main field of interest is Web Development.

You may also like...