Python Program to Find ASCII Value of Character

By | October 3, 2021
Python Program to Find ASCII Value of Character

Here we have provided a python source code that can find the ASCII value of the user entered character.

ASCII Code or value: ASCII stands for  American Standard Code or Information Interchange, and it is used to represent 128 characters as numbers, which include special symbols too.

Prerequisite topics to create this program

  • Python Input, Output
  • python ord()

Steps

  • Ask the user to enter a character.
  • Use the ord() function to find the ASCII code of the character.

Python Program to Find ASCII Value of Character:

Code:

ch = input("Enter a Character: ")
if len(ch)==0:
    print("The ASCII code of",ch,"is",ord(ch))
else:
    print("The ASCII code of",ch,"is",ord(ch[0]))

Output 1:

Enter a Character: A
The ASCII code of A is 65

Output 2:

Enter a Character: !
The ASCII code of ! is 33

People are also reading:

Author: Vinay Singh

I am a Full Stack Developer with a Bachelor's Degree in Computer Science, who also loves to write technical articles that can help fellow developers.

Leave a Reply

Your email address will not be published.