Python Program to find ASCII value of character


April 15, 2022, Learn eTutorial
1269

In this simple python program, we need to find the ASCII value of a character. It's a beginner-level python program.

To understand this example, you should have knowledge of the following Python programming topics:

What is the ASCII value of a character?

In this simple python program for beginners, we need to find the ASCII value of a character input by the user. ASCII value is American Standard Code for Information Interchange, which is a character encoding standard for representing electronic communication. It is used for computer text representation too.

How to find the ASCII value of a character in python?

Every alphabet has an ASCII value, and it's different for Upper case letters and Lower case letters. To represent the capital letters from A to Z, ASCII value uses the numbers from 65 to 90, and for the lower case numbers, it uses the number from 97 to 122.

In this basic python program, we use a built-in function in python called ord() to find the ASCII value of the corresponding alphabet. ord() accept a single letter as an argument and return its corresponding ASCII value.

ALGORITHM

STEP 1: Accept the input from the user using the input function in python and store that letter in a variable.

STEP 2: Call the built-in function ord() to convert the alphabet to the corresponding ASCII value and print the result using print statements in the python programming language.

Python Source Code

                                          c = input("Enter a character: ")  
  
print("The ASCII value is",ord(c))  
                                      

OUTPUT

Enter a character: A

The ASCII value is 65