PCPP 32 10x PCPP Certified Professional Python Programmer 1 · Free Practice Question Easy

Question 29

The Zen of Python is an Easter Egg in Python that reveals a set of guiding principles for writing Python code. If you want to recall the Zen of Python aphorisms in the console window, what instruction should you use (Easter Egg in Python)?

  • A

    import pep20

  • B

    import zen

  • C

    import pep

  • D

    import this

Reveal correct answer

Correct answer: D

A.

This is incorrect. The Zen of Python is also known as PEP 20, but import pep20 is not a valid command to display the Zen of Python. PEP (Python Enhancement Proposals) are documents that describe new features or changes in Python, but they are not imported in this manner.

B.

This is incorrect. While "Zen" refers to the Zen of Python, there is no module named zen in Python that would reveal the aphorisms.

C.

This is incorrect. PEP documents (like PEP 8, PEP 20, etc.) are not modules and cannot be imported with import pep. Therefore, this command would not display the Zen of Python.

D.

This is the correct answer. When you type import this in a Python console, it displays "The Zen of Python," which is a collection of aphorisms that capture the philosophy of Python programming. This is an Easter Egg included in Python, written by Tim Peters.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need