Python interesting facts

Afsalms
3 min readJun 4, 2021

Python has been one of the most popular programming languages for the last few years. Python’s simple syntax and large open-source support makes it very popular. Python is almost everywhere including web development, data science, AI, microprocessor. Here are some interesting facts about Python.

1. Python is on Mars

Python is used in the Mars rover made by NASA. Python packages are used to record, process the images, and videos.

2. Python is older than Java

First version of Python was first released on Feb 20, 1991 and the first version of Java was on Jan 23, 1996. But a recent increase in popularity for Python seems like it is newer compared to Java.

3. Python has multiple flavors

Python has multiple implementations in various languages. Some of them are

  1. CPython: This is the standard Python which is written in C language
  2. Jython: Here Python code is compiled using Java Byte code and executed using jvm
  3. IronPython: It is written in C# language
  4. PyPy: Python written using Python itself
  5. MicroPython: Python run on microcontrollers

4. We can define infinite value in Python

Defining infinite value is not supported by many programming languages. But Python allows the user to define infinite value.

postive_infinity = float(‘inf’)negative_infinity = float(‘-inf’)

5. Python can return multiple values

Most of the languages do not support multiple returns directly. But a Python function can have multiple returns.

code

def func():
return 1, 2
a = func()print(a)

output

(1, 2)

6. Python influences JavaScript

Python is the one of the languages that influenced the development of JavaScript. Handling of string, array, and regular expression is influenced by Python and Perl.

7. List can be reversed using slicing operator

We can easily reverse a list using the slicing operator.

code

numbers = [1, 2, 3, 4, 5]reversed = numbers[::-1]

output

[5, 4, 3, 2, 1]

8. Python is named after a television show

Python is named after a BBC comedy series Monty Python’s Flying Circus.

9. String Literal concatenation

If we type two string separated by space then python will automatically concatenate the strings.

code

a = “Hello “ “World”
print(a)

output

‘Hello World’

10. Else block for loops

Python can have “else block” for “for and while loops.” Else block get executed when there is no break in the loop.

Code without break

for i in range(5):
print(i)
else:
print(“0 to 4 printed”)

Output

0
1
2
3
4
0 to 4 printed

Code with break

for i in range(5):
print(i)
if i == 2:
break
else:
print(“0 to 4 printed”)

Output

0
1
2

11. Import this

If we import this we will get zen of python. It is a guiding principle for writing better Python code

Code

import this

Output

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!

References

https://discuss.python.org/t/python-is-running-on-mars/8312

https://docs.python.org/3/tutorial/controlflow.html

--

--