nerdexam
Python_Institute

PCEP-30-02 · Question #125

What is the default value of encoding in the string function encode()?

The correct answer is D. utf-8. Python's str.encode() method defaults to 'utf-8' encoding, making D correct - UTF-8 is the dominant encoding on the web and the Python 3 standard, so it was chosen as the sensible default. Option A (qwerty) is a keyboard layout, not a character encoding at all, making it an…

Question

What is the default value of encoding in the string function encode()?

Options

  • Aqwerty
  • Bascii
  • Cutf-16
  • Dutf-8

How the community answered

(27 responses)
  • A
    7% (2)
  • B
    4% (1)
  • C
    15% (4)
  • D
    74% (20)

Explanation

Python's str.encode() method defaults to 'utf-8' encoding, making D correct - UTF-8 is the dominant encoding on the web and the Python 3 standard, so it was chosen as the sensible default. Option A (qwerty) is a keyboard layout, not a character encoding at all, making it an obvious distractor. Option B (ascii) is a real encoding but only covers 128 characters and lacks support for non-English text, so Python didn't choose it as the default. Option C (utf-16) is also a real Unicode encoding but uses more bytes per character for common text and is less universally used than UTF-8.

Memory tip: Think "Python 3 = UTF-8 = the web standard" - the 8 in UTF-8 reminds you it uses 8-bit (1-byte) code units, making it compact and the obvious default choice.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice