Exciting Things about Python that Every User Should Know!

Himanshi Singh Last Updated : 10 Mar, 2022
8 min read

Introduction

Python is a really interesting programming language and by the end of this blog, you’ll also understand why. The IEEE Spectrum has ranked Python #1  in their list of top programming languages, 2020. It has maintained its position at #1 since the year 2017. Interesting! Isn’t it?

It definitely took some time for python to gain popularity but earlier its reach was small. By the time its reach has increased and so does its popularity. Its various features such as amazing libraries, the capability to handle big data, accessibility, efficiency, and moreover its helping and supportive community helped in gaining well-deserved fame.

I started coding in python when I was in the second year of my graduation. And believe me, I’ve not looked back at any other language since then. I like python because it values your time. Python has been in trend for so many reasons and today it is used in almost every industry.

Along with the syntax and the rules of any language, I personally love to know about the background and interesting things about the language.  If you want to learn python I have a suggestion for a course-  You can go for the Introduction to Python course.  But if you want to know some interesting facts about python, you are in the right place.

Table of Content

Interesting Things about Python-

  • Python wasn’t named after the snake
  • Python was a hobby project
  • Dynamically typed
  • Relief from braces and semicolons
  • Say hello to the world
  • Comic Time!
  • The Classic Zen of Python
  • Make way for the Walrus
  • Multiple assignments
  • Multiple return values
  • For-Else

Python for Data Science-

  • Pandas
  • Numpy
  • Matplotlib
  • Seaborn
  • Scikit Learn

Interesting Things about Python

1. Python wasn’t named after the snake

I bet you also used to think the same. Most people assume that it was named after the snake. The snake has nothing to do with the motivation behind naming the language Python.

The reason behind the name is that the developer Guido van Rossum was a big fan of a BBC’s TV show, ‘Monty Python’s Flying Circus’.  Also, he wanted a unique and short name, and what else is more unique than naming your invention PYTHON.

Monty Python's Flying Circus Poster

Source – IMDb

 

2.  Python was a hobby project

Yes! You read it right. The developer of Python, Guido van Rossum developed a language out of his hobby. He wanted to do something interesting to keep him occupied during the Christmas week and here we are praising his hobby project. Incredible! Python is the successor of a programming language called ABC.

Guido's Personal Home Page

This ABC had interfacing with the Amoeba Operating System and had the feature of exception handling. He took the syntax of ABC along with some features and removed the flaws from it and gave us this great scripting language. He started off in December 1989 and by February 1991, a new programming language was born.

3. Dynamically typed

This means that we don’t have to specify the type of variable like we used to do in Java and C. Instead we just have to write the variable name and assign a value to it. No declaration is required in Python. It stores the value at a memory location and then assigns a variable to it. And this variable is used to access the value at that particular memory location.

Syntax in Java-

int num = 2;

Syntax in Python-

num = 2
print(type(num))

Output

Also, we can change the type of variable anytime during its lifetime but this is not possible in Java or C.

 

4. Relief from braces and semicolons

We do not have to use the curly braces for defining the clear scope. Instead, we have an indentation for this. The four white spaces indentation increases the readability of the code.

Also, python lets you code without semicolons. The same semicolon which can make the life of a coder hard if you miss it in other programming languages like Java and C is not required in Python. Although Python does not generate an error for using semicolons. In fact, while writing multiple statements in the same line semicolons can be used as separators. But this is not advised as this reduces the readability which is against the Python coding standards.

Syntax in Java:

int num = 2;
if(num == 2){
System.out.println("THIS IS IF BLOCK");
}
else{
System.out.println("THIS IS ELSE BLOCK");
}

Syntax in Python:

num = 2
if num == 2:
    print("THIS IS IF BLOCK")
else
    print("THIS IS ELSE BLOCK")

But if you want to mess with Python then try importing braces from __future__ module and wait for the humorous reply from python in the form of an error.

from __future__ import braces 

Output-

 

As many people say- Congratulation! you’ve found an Easters egg. This is nothing less than that. This error tells us how determined the Python is for not using braces in its code. Be like Python!

 

5. Say hello to the world

How simple can a hello world program be? It is this simple- import __hello__

import __hello__

Output-

Ah! another gem from Python.

6. Comic Time!

The creativity of the python developers didn’t stop here. And they managed to make another way to astonish us. Try-

import antigravity

What do you think this will do? This will make you fly 😉

This code will redirect you to a web page that showcases a classic comic on python by XKCD.

Exciting Things about Python

 

7. The Classic Zen of Python

If you know you know. But if you do not know about this then this might get you into trouble among your geeky friends. Don’t worry I’m here to help you out.

So back in 2004, Pythoneer Tim Peters decided to show the world Guido van Rossum’s guiding principles for Python design. But in a very creative poetic way, you must say. He wrote 20 aphorisms about how to write neat code in Python. But only 19 are mentioned in the poem and the 20th aphorism is still a mystery. Maybe one more Easter Egg is hidden somewhere and no one has yet figured it out. Maybe you might find that!

Guido van Rossum reportedly said that the missing 20th aphorism is “some bizarre Tim Peters in-joke.” 

For reading the famous Zen of Python you need to import this, yes “this“.

import this

And you’ll see a poem like this-

The Zen of Python, by Tim Peters

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!

 

This requires a high-level IQ to understand the depth of this poem. You can understand the line by line explanation from here.

 

8. Make way for The Walrus 

The latest version of Python- Python 3.8,  has introduced a new operator called “Walrus operator:=”. It is affectionately known as “the walrus operator” due to its resemblance to the eyes and tusks of a walrus. How cool is that!

This operator allows you to assign and return a value in the same expression.

var1 = True
print(var1)

Output-

You can combine these two statements as-

print( var1 := True)

Output-

You can learn about this new operator along with all the new features of Python 3.8 in detail from here.

 

9. Multiple assignments

There are various ways of performing multiple assignments. One way could be assigning the same value to multiple variables-

var_1 = var_2 = var_3 = 13
print(var_1,var_2,var_3)

Output-

Another way could be assigning different values to different variables in a single line-

var_1, var_2, var_3 = 12, 13, 14
print(var_1, var_2, var_3)

Output-

    10. Multiple Return Values

Remember how c and Java did not let us return multiple values at a time from a function. Well, Python solves this problem as well.

def car():
  name = 'Tesla'
  price_in_crores = 1.5
  color = 'Black'

  return name, price_in_crores, color
Name, Price, Color = car()
print("Car Name is",Name,"\n","Price is",Price,"Crores","\n","Color is",Color)

Output-

MAGIC!!

    11. For-Else

No, I haven’t written it wrong. Do you know you can use the “else” clause with a “for” loop as well, provided the loop runs naturally without any control statements such as break? Here is an example-

list_1 = [4]
for i in list_1:
  if i % 3 == 0:
    print(i)
else:
  print("Else part")

Output-

Python for Data Science

Python is one of the most widely used languages in the field of Data Science. One of the main reasons is the inbuilt libraries which are used for various tasks such as data mining, data pre-processing, data visualization, and whatnot. These libraries are really helpful and save a lot of time. Here is a list of some famous python libraries-

    Pandas

Pandas is a very powerful library. It is used for data manipulation and analysis. It provides data structures and various operations that ease the process of analysis. The data structures it provides are Data frame(two-dimensional) and Series(one-dimensional). It is used for reading various types of files such as CSV files, HTML files, excel files, etc. And then converting these files into data-frames for performing various operations such are merging, splitting, finding missing values, imputing missing values, etc.

    Numpy

For mathematical computing and N-dimensional array-based operations, we use Numpy. It supports an object-oriented approach. Some of the basic mathematical operations it can perform are sum, product, rounding, linear algebra, trigonometric functions, hyperbolic functions, etc. Some of its array related functions are slicing, reshaping, flattening, indexing, etc.

You can learn about Numpy in detail from here.

    Matplotlib

This is the standard data visualization library of python for plotting 2-D graphs. It allows all types of analysis i.e univariate, bivariate, and multivariate analysis. It has a vast range of graphs and plots such as boxplots, bar graphs, violin plots, scatter plots, histograms, box plots, line charts, and whatever plot you can name.

    Seaborn

It is also widely used for data visualization based on matplotlib. Seaborn makes our charts and plots look engaging and enables some of the common data visualization needs (like mapping colour to a variable or using faceting). Basically, it makes data visualization and exploration easy to conquer.  Seaborn comes with a large number of high-level interfaces and customized themes that matplotlib lacks as it’s not easy to figure out the settings that make plots attractive.

If you want to explore more data visualization libraries then you can go here.

     Scikit Learn

This library is built on top of other Python libraries like pandas, numpy, etc. It is used for implementing Supervised Machine learning algorithms like for classification: k-NN, Logistic regression, Support vector machine, etc, for regression: linear regression, Decision trees, etc and also for the Unsupervised Machine learning algorithms like k-means.

You can learn more about Scikit learn from here.

 

End Notes

So these were just a few things that make Python interesting & different from other languages and everyone should know these. This article didn’t focus on the technical aspect of python, for that you can refer to the course referred to in the beginning. Instead, its purpose was just to showcase the fun and interesting side of Python which makes it more famous in the IT industry. I hope you enjoyed reading these as much as I enjoyed writing down these altogether.

I’m a data lover who enjoys finding hidden patterns and turning them into useful insights. As the Manager - Content and Growth at Analytics Vidhya, I help data enthusiasts learn, share, and grow together.

Thanks for stopping by my profile - hope you found something you liked :)

Responses From Readers

Clear

Briana technology
Briana technology

Thanks for sharing! This website is very informative. I appreciate this website. This introduction to Python will kickstart your learning of Python for data science, as well as programming in general. This beginner-friendly Python course will take you from zero to programming in Python in a matter of hours.

Congratulations, You Did It!
Well Done on Completing Your Learning Journey. Stay curious and keep exploring!

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details