The ord() function is  used to return the Unicode integer code of a specified character. The function takes a string containing a single character as its only argument.

syntax:

ord(character)
ExampleEdit & Run
print(ord('a'))
print(ord('n'))
print(ord('z'))
Output:
97 110 122 [Finished in 0.028819440000000363s]
ExampleEdit & Run
for i in 'Python':
    print("{} : {}".format(i, ord(i)))
Output:
P : 80 y : 121 t : 116 h : 104 o : 111 n : 110 [Finished in 0.013263569000000253s]

The argument given should strictly be a single character.

ExampleEdit & Run
ord('Python')
Output:
TypeError: ord() expected a character, but string of length 6 found [Finished in 0.01228420799999963s]

The chr function serves the opposite purpose, where you give it an integer argument and it returns the unicode character represented by the integer.