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 String capitalize()
Python Tuple
Python String endswith()
Python Dictionary popitem()
Python Program to Delete an Element From a Dictionary
Python String replace()
Python complex()
Python Program to Reverse a Number
Python Dictionary pop()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python locals()
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python filter()
Python property()
Python format()
Python Data Structures and Algorithms - Benjamin Baka
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Program to Get File Creation and Modification Date
Python Program to Safely Create a Nested Directory
Python slice()
Python Set intersection_update()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Iterate Over Dictionaries Using for Loop
Python Program to Calculate the Area of a Triangle
Python Program to Check Prime Number
Python setattr()
Python max()
Python Set copy()
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python List extend()
Python Program to Differentiate Between del, remove, and pop on a List
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar