Table of Contents
In this tutorial, we will learn about the Python ord() function with the help of examples.
The ord()
function returns an integer representing the Unicode character.
Example
character = 'P' # find unicode of P unicode_char = ord(character) print(unicode_char) # Output: 80
1. ord() Syntax
The syntax of ord()
is:
ord(ch)
2. ord() Parameters
The ord()
function takes a single parameter:
- ch – a Unicode character
3. ord() Return Value
The ord()
function returns an integer representing the Unicode character.
4. Example: How ord() works in Python?
print(ord('5')) # 53 print(ord('A')) # 65 print(ord('$')) # 36
Output
53 65 36
By the way, the ord()
function is the inverse of the Python chr() function.
Related posts:
Python sum()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python locals()
Python String istitle()
Python Dictionary pop()
Python Type Conversion and Type Casting
Python String swapcase()
Python String isnumeric()
Python input()
Python Program to Find Factorial of Number Using Recursion
Python Program to Sort a Dictionary by Value
Python Program to Print Colored Text to the Terminal
Python hasattr()
Python next()
Python String lstrip()
Python List index()
Python Program to Convert String to Datetime
Python map()
Python String expandtabs()
Python String isidentifier()
Python String split()
Python List count()
Python List extend()
Python List pop()
Python Operators
Python min()
Python Set intersection()
Python Program to Differentiate Between type() and isinstance()
Python String format_map()
Node.js vs Python for Backend Development
Python del Statement
Python Program to Find the Size (Resolution) of a Image