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 pow()
Python List reverse()
Python List
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python Program to Get File Creation and Modification Date
Python min()
Python Program to Get the Class Name of an Instance
Python filter()
Python ascii()
Python Program to Print Output Without a Newline
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Statement, Indentation and Comments
Python Program to Find Numbers Divisible by Another Number
Python Custom Exceptions
Python Dictionary get()
Python Dictionary update()
Python Function Arguments
Python Set update()
Python String index()
Python List clear()
Python Program to Create Pyramid Patterns
Python Program to Find Sum of Natural Numbers Using Recursion
Python Data Types
Python exec()
Python Program to Find the Size (Resolution) of a Image
Python Set clear()
Python Set union()
How to Get Started With Python?
Python Program to Check If a List is Empty
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Node.js vs Python for Backend Development
Python while Loop