import this
The Zen of Python を表示する方法と、それを定めた PEP の組み合わせとして、最も適切なものを1つ選べ。
- A
import zenを実行する。PEP 8 に書かれている。 - B
import thisを実行する。PEP 257 に書かれている。 - C
help("zen")を実行する。PEP 484 に書かれている。 - D
import thisを実行する。PEP 20 に書かれている。
正解と解説を見る
正解:D
import this で The Zen of Python が表示される。定めた PEP は PEP 20。PEP 8 はコーディング規約、PEP 257 は docstring、PEP 484 は型ヒント。
| 格言 | 意味 |
|---|---|
| Beautiful is better than ugly. | 美しい方が、醜いよりよい |
| Explicit is better than implicit. | 明示的な方が、暗黙的よりよい |
| Simple is better than complex. | 単純な方が、複雑よりよい |
| Complex is better than complicated. | 複雑でも、ごちゃごちゃ(complicated)よりはよい |
| Flat is better than nested. | 平らな方が、入れ子より(深い入れ子より)よい |
| Sparse is better than dense. | ゆとりのある方が、詰め込みよりよい |
| Readability counts. | 読みやすさは大事 |
| Special cases aren't special enough to break the rules. | 特別な場合でも、規則を破るほど特別ではない |
| Although practicality beats purity. | ただし、実用性は純粋さに勝る |
| Errors should never pass silently. | エラーを黙って見過ごしてはいけない |
| Unless explicitly silenced. | 明示的に黙らせた場合は別 |
| In the face of ambiguity, refuse the temptation to guess. | あいまいなときは、推測したくなる誘惑を断る |
| There should be one-- and preferably only one --obvious way to do it. | 明白なやり方が1つ、できればただ1つだけあるべき |
| Although that way may not be obvious at first unless you're Dutch. | その方法は、オランダ人でなければ最初は分かりにくいかもしれない |
| Now is better than never. | やらないよりは、今やる方がよい |
| Although never is often better than *right* now. | ただし、「今すぐ」よりやらない方がよいことも多い |
| If the implementation is hard to explain, it's a bad idea. | 実装を説明しにくいなら、悪い考え |
| If the implementation is easy to explain, it may be a good idea. | 実装を説明しやすいなら、よい考えかもしれない |
| Namespaces are one honking great idea -- let's do more of those! | 名前空間は素晴らしい考え。もっと活用しよう |
- A
誤り。PEP 8 は、コーディング規約。
- B
誤り。PEP 257 は docstring の規約。
- C
誤り。PEP 484 は、型ヒント。
- D
正しい。PEP 20 は「The Zen of Python」。
このサイトの問題は、各試験の公式に示された出題範囲に沿って作ったオリジナルの模擬問題です。本試験の問題ではありません。一般社団法人Pythonエンジニア育成推進協会の公式サービスではありません。