Python ord Function with Examples - Python Tutorial | Logic Practice
Python Course / Other / Python ord Function with Examples

Python ord Function with Examples

BLUF: This lesson on Python ord Function with Examples provides a comprehensive guide to understanding and implementing this concept in Python. Whether you're a beginner or looking to refresh your knowledge, you'll find clear explanations and interactive code examples here.
Key Concept: Python ord Function with Examples

Mastering Python ord Function with Examples is essential for building efficient Python applications. Focus on the syntax and the best practices highlighted in this tutorial.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience