Python Program to Find ASCII Value of Character | ASCII Value in Python

Posted in

Python Program to Find ASCII Value of Character | ASCII Value in Python

Vinay Khatri
Last updated on August 22, 2022

    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 A merican S tandard C ode or I nformation I nterchange, and it is used to represent 128 characters as numbers, which include special symbols too.

    Prerequisite To Calculate ASCII Value in Python

    • 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:

    Python 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:

    Leave a Comment on this Post

    0 Comments