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 Program to Display the multiplication Table
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python map()
How to get current date and time in Python?
Python File I/O Operation
Python callable()
Python String isidentifier()
Python String islower()
Python Program to Find ASCII Value of Character
Python Program to Get Line Count of a File
Python float()
Python String encode()
Python Program to Merge Mails
Python String rjust()
Python Data Structures and Algorithms - Benjamin Baka
Python List reverse()
Python String zfill()
Python Program to Check Prime Number
Python String isupper()
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Program to Create a Long Multiline String
Python String replace()
Python Program to Check if a Key is Already Present in a Dictionary
Python String title()
Python Set intersection_update()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python hasattr()
Python Program to Get a Substring of a String
Python Recursion
Python List remove()
Python Program to Find the Factorial of a Number
Python Program to Convert Celsius To Fahrenheit