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

Question 19

The Zen of Python says "Beautiful is better than ugly."


With that in mind, which code best fits that sentence?

  • A
  • B
  • C
  • D
Reveal correct answer

Correct answer: A

A.

This code is clean and readable. It uses pathlib for path manipulations, which is more modern and expressive compared to older methods. The zipfile operations are also clear and concise. The overall structure of the code is simple and aligns well with the Zen of Python by being clear and straightforward.

B.

This option is almost identical to the correct option, but it has a trailing space at the end of the with statement's block. Although this doesn't impact functionality, it slightly affects the code’s readability and cleanliness.

C.

This code demonstrates the use of functools.partial to simplify function calls. While it is clean and functional, it is more complex than necessary for a simple demonstration, which may detract from its elegance compared to the straightforward approach in the correct option.

D.

This code is functional and does the job, but it is less directly related to the principle of "beautiful" code because it involves multiple steps that are less straightforward and can be seen as more complex compared to the simple operations in the correct option.

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