Python ord()

The ord() method returns an integer representing Unicode code point for the given Unicode character.

The syntax of ord() is:

ord(c)

The ord() method is the inverse of chr().


ord() Parameters

The ord() method takes a single parameter:

  • c - character string of length 1 whose Unicode code point is to be found

Return value from ord()

The ord() method returns an integer representing the Unicode code point of the given Unicode character.


Example 1: How ord() works in Python?

# code point of integer
print(ord('5'))

# code point of alphabet 
print(ord('A'))

# code point of character
print(ord('$'))

When you run the program, the output will be:

53
65
36