12 Fascinating Python Facts
Ohidur Rahman Bappy
MAR 22, 2025
Introduction
Python, a versatile and popular programming language, has some intriguing aspects that make it unique. Here are 12 fun facts about Python you might not know.
1. Python Started as a Hobby Project
Guido Van Rossum initiated Python as a hobby project in December 1989.
2. The Zen of Python
Type import this
in your Python terminal to discover The Zen of Python, an easter egg that offers guiding principles for writing computer programs:
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than 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.
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!
3. Varieties of Python
Python is available in various flavors:
- CPython: The standard implementation written in C.
- Jython: Compiles Python to Java bytecode.
- IronPython: Works with .NET languages, implemented in C#.
- Brython: Python for the web browser.
- RubyPython: Bridges Python and Ruby interpreters.
- PyPy: Fast implementation written in Python.
- MicroPython: Runs on microcontrollers.
4. No Braces
Unlike Java or C++, Python uses indentation instead of braces for code separation. Using from __future__ import braces
humorously results in an error.
5. Antigravity Module
Entering import antigravity
in Python IDLE opens a web comic about the antigravity module.
6. Python Influenced JavaScript
Python is one of the nine languages that influenced the design of JavaScript. Others include AWK, C, HyperTalk, Java, Lua, Perl, Scheme, and Self.
7. Underscore for Last Expression
In the Python shell, use _
to refer to the value of the last executed expression:
>>> 3*5
15
>>> 2*_
30
8. Loops with Else
for
and while
loops can include an else
statement, executed only if the loop finishes without hitting a break
:
def func(array):
for num in array:
if num % 2 == 0:
print(num)
break
else:
print("No even number found.")
func([1, 3, 5])
func([4, 5, 6])
9. Implicit String Concatenation
Adjacent string literals concatenate automatically:
"Hello" "World" # Results in 'HelloWorld'
10. Multiple Return Values
Python functions can return multiple values:
def func():
return 1, 2, 3, 4, 5
one, two, three, four, five = func()
print(one, two, three, four, five)
11. Handling Infinity
Python supports positive and negative infinity:
p_infinity = float('Inf')
if 99999999999999 > p_infinity:
print("The number is greater than Infinity!")
else:
print("Infinity is greatest")
n_infinity = float('-Inf')
if -99999999999999 < n_infinity:
print("The number is lesser than Negative Infinity!")
else:
print("Negative Infinity is least")
Conclusion
Python is a language full of hidden gems and unique characteristics that contribute to its widespread popularity and versatility.