chr(): string representing the character associated with the specified Unicode (ASCII) code

chr() : Getting Char using Unicode point value as input

Input : takes Unicode point value as input .
returns the equivalent char

Here are some sample outputs of Unicode point value as input ( output is shown against each row after comment )
print(chr(97)) # a
print(chr(98)) # b
print(chr(80)) # P
print(chr(35)) # #
print(chr(36)) # $
The first 128 unicode point values are same as ASCII values.

We can use inputs from 0 to 1114111.

Here is for loop to print some chars with their Unicode point values (Unicode value as inputs). Change the range values to get different set of chars and values.
for i in range(200,250):
    print(i,":",chr(i))

Example 1: Printing Special Characters

print(chr(64))  # Output: '@'
print(chr(8364))  # Output: '€' (Euro sign)
Output:
@
€

Example 2: Using chr() in a Range

for i in range(65, 70):
    print(i, ":", chr(i))  # Prints characters from A to E
Output:
65 : A
66 : B
67 : C
68 : D
69 : E

Example 3: Converting Numbers to Emoji Characters

print(chr(128512))  # Output: πŸ˜€ (Smiling face emoji)
Output:
πŸ˜€

Example 4: Displaying More Emoji Characters

print(chr(128512))  # πŸ˜€ (Grinning Face)
print(chr(128516))  # πŸ˜„ (Smiling Face)
print(chr(128525))  # 😍 (Heart Eyes)
print(chr(128640))  # πŸš€ (Rocket)
print(chr(128170))  # πŸ’ͺ (Flexed Biceps)
Output:
πŸ˜€
πŸ˜„
😍
πŸš€
πŸ’ͺ

Example 5: Using chr() to Generate Lowercase Alphabet

alphabet = [chr(i) for i in range(97, 123)]
print(alphabet)  # Output: ['a', 'b', 'c', ..., 'z']
Output:
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Difference between ord() and chr() in Python

ord(): Converts a character into its corresponding Unicode code point (an integer).

print(ord('A'))  # Output: 65

chr(): Converts a Unicode code point (an integer) into its corresponding character.

print(chr(65))  # Output: 'A'

ord() and chr() are inverse functions, commonly used for character-to-integer and integer-to-character conversions in Python.


All Built in Functions ord() returns the Unicode point value by taking the Char as input ascii()
Subhendu Mohapatra β€” author at plus2net
Subhendu Mohapatra

Author

πŸŽ₯ Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer