Python ord Function with Examples

The Python function ord provides an integer that signifies the Unicode code point for a specified Unicode character.

Python ord Function Syntax

It has the following syntax:

Example

ord(character)

Parameters

  • character: A string consisting of a single character.
  • Return

It yields an integer that signifies the Unicode code point corresponding to the specified Unicode character.

Python ord Function Example

The following example demonstrates how the ord function operates in Python.

Example

# Code point of an integer

print(ord('8'))

# Code point of an alphabet

print(ord('R'))

# Code point of a character

print(ord('&'))

Output:

Output

56

82

38

Explanation:

In the preceding illustration, it produces an integer that signifies the Unicode code point for the specified Unicode character.

Input Required

This code uses input(). Please provide values below: