Python Interesting Facts

- By Pratyush Mishra

·

3 min read

Python Interesting Facts

Hi everyone👋 , In this article, we will discuss the Facts and the advantages of Python. You can listen to my podcast on YouTube.

Python has been one of the most popular programming languages for the last few years. Python’s simple syntax and large open-source support make 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

CPython : This is the standard Python which is written in C language

Jython : Here Python code is compiled using Java Byte code and executed using jvm

IronPython : It is written in C# language

PyPy : Python written using Python itself

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 gets 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

Alright, guys! I hope this article was helpful for you if it is the leave your comments below. I will meet you in another article until then KEEP CODINGđŸ€—.

References

Â