Reference Materials
Certification Courses
Created with over a decade of experience and thousands of feedback.
Python ord()
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
ord() Syntax
The syntax of ord() is:
ord(ch)
ord() Parameters
The ord() function takes a single parameter:
- ch - a Unicode character
ord() Return Value
The ord() function returns an integer representing the Unicode character.
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.
Also Read:
Did you find this article helpful?