Python ord() FunctionPython Functions


The ord() function returns the ASCII value corresponding to the character.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print("ord('a'):  ", ord('a'))

print("ord('A'):  ", ord('A'))

print("ord('C'):  ", ord('C'))

print("ord('z'):  ", ord('z'))

Output:

ord('a'):   97
ord('A'):   65
ord('C'):   67
ord('z'):   122

Syntax

ord(c)

Parameters

Name Description
c Character

Return Value

It returns the ASCII value corresponding to the character.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us