Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python program to get the ASCII value of a character


In this example shows, how to get ascii value of character using ord() method in python.

  • ASCII stands for American Standard Code for Information Interchange.
  • The built-in function ord() returns the ascii value from a given character.
example.py
ch="A"
print("The ASCII value of "+ch+" is ",ord(ch))

ch="a"
print("The ASCII value of "+ch+" is ",ord(ch))

ch="1"
print("The ASCII value of "+ch+" is ",ord(ch))

ch="@"
print("The ASCII value of "+ch+" is ",ord(ch))

Output

The ASCII value of A is  65
The ASCII value of a is  97
The ASCII value of 1 is  49
The ASCII value of @ is  64

Prev Next