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 Add Two Numbers
Python Dictionary copy()
Python List extend()
Python __import__()
Python List count()
Python complex()
Python chr()
Python Program to Trim Whitespace From a String
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python Set symmetric_difference()
Python String maketrans()
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python open()
Python Program to Check If a String Is a Number (Float)
Python globals()
Intelligent Projects Using Python - Santanu Pattanayak
Python String replace()
Python Set union()
Python Program to Display Fibonacci Sequence Using Recursion
Python Data Structures and Algorithms - Benjamin Baka
Python Program to Create a Countdown Timer
Python Program to Calculate the Area of a Triangle
Python Program to Reverse a Number
Python Directory and Files Management
Python hash()
Python Set issubset()
Python String isalpha()
Python Program to Get the Last Element of the List
Python Statement, Indentation and Comments
Python Program to Find the Size (Resolution) of a Image
Python Program to Convert Two Lists Into a Dictionary
Python Keywords and Identifiers