overview of ord()
The ord() function returns the integer representation of the given unicode character. It is the reverse function of chr(), which returns the unicode character from the given integer representation.
use of ord()
The ord() function is used to convert any Unicode character to its integer representation.
# use of ord() function
a = ord('a')
b = ord('b')
c = ord('c')
The letters 'a', 'b', and 'c' are converted to integer representations and then assigned to the variables a, b, and c. Then, the variables are printed.
The integers can be reversed to the unicode characters by the chr() function.
syntax of ord()
The syntax of the ord() function is:
arguments of ord()
The ord() function accepts a single parameter, which is required. The argument is the unicode character to be returned as an integer representation.
If no argument or a wrong type or argument is provided, a TypeError exception is raised.
return value of ord()
The ord() function returns an integer value representing the Unicode character.