liveBook · Manning

Chr

As explained in Tiny Python Projects: Learn coding and testing with puzzles and games

chr() is a Python built-in function that returns the character represented by an integer code point.

chr() is a Python built-in function that converts an integer code point into its character. It reverses ord(), which converts a character into its ordinal value. section 18.1.2

Convert ASCII values back to characters

>>> chr(68) 'D' >>> chr(111) 'o' >>> [chr(n) for n in range(ord('a'), ord('z') + 1)] ['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']

>>> chr(68)
'D'
>>> chr(111)
'o'

A compact REPL listing makes chr()'s reverse relationship to ord() immediately testable. section 18.1.2

How Tiny Python Projects: Learn coding and testing with puzzles and games covers it

How deep it goes
Explains the inverse relationship with ord() and demonstrates ranges and mappings, but does not descend into Unicode implementation details.
Examples
Demonstrates chr(68), chr(111), lowercase-letter generation, vowel mappings, and readable translation-table output.
What it assumes
Assumes familiarity with Python strings, integers, loops, ranges, and ord(); introduces their relationship through short REPL examples.
What you can do after
Apply chr() to reconstruct characters from ASCII values and inspect numeric character mappings.
How it connects
Connects chr() to ord(), ASCII, regular expressions, string translation, dictionaries, and character ranges.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny Python Projects: Learn coding and testing with puzzles and games. The section links point to the parts of the book it draws on.