Notes

`chr()` Function in Python [ English ]

< Prev Next >

1. Introduction

The chr() function in Python is a built-in function used to convert an integer (Unicode code point) into its corresponding character. In simple terms, it returns the character represented by a given ASCII or Unicode value.

Computers store characters internally as numeric codes, and the chr() function helps convert those numeric codes into readable characters.

2. Syntax

chr(number)

Parameter

3. Return Value

4. Basic Example

print(chr(65))

Output

A

Explanation

5. Example with Another Value

print(chr(97))

Output

a

Explanation

6. Example with Special Characters

print(chr(36))

Output

$

Explanation

7. Example with Unicode Characters

print(chr(9731))

Output

Explanation

8. Practical Example

for i in range(65, 71):
    print(chr(i))

Output

A
B
C
D
E
F

Explanation

9. Relationship Between chr() and ord()

Function Purpose
chr() Converts a Unicode number to a character
ord() Converts a character to its Unicode number

Example:

print(chr(65))
print(ord('A'))

Output:

A
65

10. Summary

< Prev Next >