Program to find ASCII value of a Character in Python

Program to find ASCII value of a Character in Python. This program includes input, print and ord() inbuilt functions. This is for beginners, class 11, 12 and B Tech computer science students.

Program to find ASCII value of a Character in Python.

What is ASCII ?

ASCII, abbreviation of American Standard Code For Information Interchange, a standard data-transmission code that is used by smaller and less-powerful computers to represent both textual data (letters, numbers, and punctuation marks) and noninput-device commands (control characters). A specific numerical value is given to different characters and symbols for computers to store and manipulate in ASCII. It is case sensitive. The same character, having different formats (upper case and lower case), has a different value. For example, The ASCII value of “A” is 65 while the ASCII value of “a” is 97.

Source code :

K = input("Please enter a character: ")    
    
print ("The ASCII value of '" + K + "' is ", ord(K))

Download Source code : For Download Click on the below Button

Step wise Source code Explanation :

Step 1 : Input of character is done.
K = input(“Please enter a character: “)
Step 2 : The numeric value of ASCII is calculated and printed. ord(k) function calculates the numeric value.
print (“The ASCII value of ‘” + K + “‘ is “, ord(K))

Output :

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
 RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/test1.py 
Please enter a character: y
The ASCII value of 'y' is  121
>>> 
 RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/test1.py 
Please enter a character: w
The ASCII value of 'w' is  119
>>> 
 RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/test1.py 
Please enter a character: i
The ASCII value of 'i' is  105
>>> 

Output Explanation :

A character is taken as input.
Please enter a character: i
ASCII value is printed.
The ASCII value of ‘i’ is 105

Conclusion :

Program is running fine.

Thank you for reading and learning from Program to find ASCII value of a Character in Python post. This program includes input, print and ord() inbuilt functions. This program provides insight on the in-built functions of the python like the use of ord(). Similarly the python has a huge library of the functions plus the in-built functions. That is why python has became so popular. This is for beginners, class 11, 12 and B Tech computer science students. More programs for practice are given in link below.
Python Programs Archives – CS Study
Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
Computer Science Practical file for class 12 Term-2 – CS Study

Leave a Comment

Your email address will not be published.