Write a Python Program to Find ASCII Value of Character

In Python, we can easily find the ASCII value of a character using the built-in ord() function.

The ord() function takes a single argument, which is a string of length 1 representing the character whose ASCII value we want to find.

The function returns an integer representing the ASCII value of the given character.

Here’s a Python program that demonstrates how to use the ord() function to find the ASCII value of a character:

# Python program to find the ASCII value of a character

# take input character from the user
character = input("Enter a character: ")

# find the ASCII value using ord() function
ascii_value = ord(character)

# print the ASCII value
print(f"The ASCII value of {character} is {ascii_value}.")

In the above program, we first take an input character from the user using the input() function.

Then, we pass this character to the ord() function to find its ASCII value.

Finally, we print the ASCII value using the print() function.

Let’s run this program and see if it works as expected:

Enter a character: A
The ASCII value of A is 65.

As you can see, the program correctly found the ASCII value of the character ‘A’, which is 65.

Similarly, we can find the ASCII values of other characters by entering them as input to the program.


In conclusion, finding the ASCII value of a character in Python is very easy using the ord() function.

All you need to do is pass the character to the function and it will return the corresponding ASCII value.