The Zen of Python
Check out the twenty principles of the Zen of Python for good programming practices with examples.
Before concluding the course, let’s look at the Pythonic principles of good code with simple examples. These principles are grouped in the Easter egg this.py
module. Let’s recap the twenty principles of the Zen of Python with examples.
Make code readable
Beautiful is better than ugly.
Sparse is better than dense.
Readability counts.
Here’s an example. We have a list of numbers. The squares of all numbers are calculated, and then the sum of these squares is calculated. There are two implementations of the same problem: one is sparse, and the other is dense.
Get hands-on with 1400+ tech skills courses.