CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Encodings and Code Points

PCAP objective 3.1 is understand machine representation of characters, and it is the one string objective that is really about types. A str is a sequence of code points; a bytes is a sequence of numbers 0-255. encode turns the first into the second and decode goes back, and the two lengths do not have to match - café is four characters and five UTF-8 bytes. Everything else in the objective follows from that.

Strings in Depth Guide 9 of 25 Intermediate

Python 3 made str Unicode and bytes a separate type, which is the single largest Python 2 to 3 change. Anything using unicode(...) or str.decode() is Python 2. The default source encoding is UTF-8 and has been since 3.0.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

This guide includes

Use this for the character-representation objective. This matters because nothing in a byte says which encoding produced it - so the same bytes read two ways give two different answers, and only one of them is your text.

Before you start

  1. A string is a sequence of code points

  2. str and bytes are different types

  3. The same text in three encodings

  4. How encoding and decoding fail

  5. The same bytes read two ways

  6. What bytes actually contain

  7. ASCII, and the default

  8. What the exam does with this objective

Official sources