Python Reference Library →

Python chr() Function – Get Character from Unicode Code Point

Let’s look at chr() function – get character from unicode code point

  1. Notice

    chr() returns the character for a Unicode code point. It is the reverse of ord() for a single character.

  2. Try

    Follow the example, change its sample, and compare what happens.

  3. Check

    Explain the result and test your understanding.

Watch how it works

Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.

Explore the idea

Follow the code and watch its state change. Guided simulation.

Code
Python
code_point = 65
print(chr(code_point))
Live state

Top-level scope

code_point→Object 1
Object 1 · int65
This step

chr() returns the character for a Unicode code point. It is the reverse of ord() for a single character.

Picture chr() function – get character from unicode code point

chr() returns the character for a Unicode code point. It is the reverse of ord() for a single character.

Image brief

Alt text
A diagram for Python chr() Function – Get Character from Unicode Code Point. Instructions: code_point = 65 print(chr(code_point)). Displayed result: A. The final example bindings are code_point --> object 1 (int). object 1: 65
Image generation prompt
Create a clean educational illustration for a Python programming lesson titled "Python chr() Function – Get Character from Unicode Code Point". Teaching focus: chr() returns the character for a Unicode code point. It is the reverse of ord() for a single character. Depict exactly the relationships and labels in this reference diagram: EXAMPLE INSTRUCTIONS code_point = 65 print(chr(code_point)) | v DISPLAYED RESULT A FINAL BINDINGS code_point --> object 1 (int) object 1: 65 Use a flat vector style, generous spacing, clear arrows and legible labels, with a restrained blue/teal palette on a plain background. The diagram must explain the programming idea accurately. Do not depict variables as boxes containing copied objects when they share a reference. Avoid mascots, decorative screenshots, logos, gradients and extra text. Landscape composition, approximately 3:2, suitable for a course card. Accessible description: A diagram for Python chr() Function – Get Character from Unicode Code Point. Instructions: code_point = 65 print(chr(code_point)). Displayed result: A. The final example bindings are code_point --> object 1 (int). object 1: 65

Follow the execution

Choose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.

Execution workspace

Choose a sample and follow its execution. Guided simulation.

Code
Python
code_point = 65
print(chr(code_point))
Live state

Top-level scope

code_point→Object 1
Object 1 · int65
This step

The example has finished. Compare the final output with the values and references above.

Terminal
Output
A

What do you expect this program to print?

What does this example display?

code_point = 65
print(chr(code_point))
What does this example display?
Choose one answer. You can try again.

Answer and explanation

A

Follow the printed values in order. The output is: A

More examples and reference

Python chr() Function

The chr() function in Python returns the character that represents the specified Unicode code point (an integer). It’s the opposite of ord(), which gives the Unicode number for a character.

Syntax

chr(i)

Parameters:

  • i – An integer representing the Unicode code point (between 0 and 1,114,111)

Returns:

  • The string representing the character whose Unicode code point is i

Example 1: Basic Usage

print(chr(65))
A

This is because the Unicode code point 65 maps to the character 'A'.

Example 2: Lowercase Letter

print(chr(97))
a

Example 3: Symbols and Special Characters

print(chr(36))   # Dollar sign
print(chr(8364)) # Euro sign
$
€

Example 4: Creating Alphabets Using chr()

for i in range(65, 91):
    print(chr(i), end=" ")
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

Use Case: Why Use chr()?

  • To generate characters programmatically
  • Useful in ASCII/Unicode manipulation tasks
  • Often used in algorithms and encryption tasks (like Caesar cipher)

Common Mistakes

  • Out of range: Passing a number below 0 or above 1,114,111 will raise a ValueError
  • Non-integer: Passing a float or string will raise a TypeError

Interview Tip

The chr() and ord() functions often appear together in string manipulation or encryption interview problems.

Summary

  • chr(i) converts a Unicode code point to a character
  • Only accepts integers between 0 and 1,114,111
  • Opposite of ord(), which converts a character to a number

Practice Problem

Write a Python program to print all characters from Unicode 97 to 122 on one line (a to z).

for i in range(97, 123):
    print(chr(i), end=" ")

What to remember

Connect what you noticed in the example with the idea below.

Remember

chr() returns the character for a Unicode code point. It is the reverse of ord() for a single character.

Watch out for this idea

chr() returns the decimal digits of its argument.

This is the misconception to avoid.

Reference checks are optional and do not count toward course progress.

    Reference library →