Why You Should Learn Python?

Python is one of the most popular and widely used programming languages of today. It’s applied by beginners and professionals, startups and large companies, academia and commercial entities. As a general-purpose and multi-platform programming language, it has a variety of applications. Python and most of the stuff in its ecosystem are free and open-source. There is a large, dedicated, and friendly community of developers and educators who support the development of Python and the related libraries and help people learn and master Python.

Python has a nice and elegant syntax that allows you to write concise and readable code. The development process is generally very fast because of the language features, a large number of useful libraries in many areas, excellent community support, excellent support for most of the major integrated development environments, and so on.

This article explains some of the factors that make Python so popular and attractive.

1. Python Is Free and Open-Source

Python interpreter itself and the majority of the most popular third-party libraries are free and open source. Python is licensed under a very permissive Python Software Foundation (PSF) License. Other software is usually licensed under quite permissive licenses like PSF (BitArray), BSD 3-Clause (NumPy, SciPy, Pandas, Django, Flask, IPython, Jupyter, Bokeh, PyTorch, Scikit-Learn), MIT (BeautifulSoup4, Flake8, PEP8, IP, Spyder), Apache 2.0 (TensorFlow, ElasticSearch, NLTK, Tornado), LGPL 3.0 (Qt), and so on.

Python is one of the most popular languages in the world. It’s also the language developers love to use. On the Tiobe Index list for August 2019, Python is the third, behind Java and C, and in front of C++ and C#. According to the Stack Overflow’s annual Developer Survey for 2019, Python is just behind JavaScript (and also HTML/CSS and SQL). According to the same survey, it’s the most desired programming language and the second most loved, after Rust.

Python third-party libraries are also very popular. According to the survey mentioned above, Pandas is the fourth most loved and 12th most wanted among all frameworks, libraries, and tools. Django and Flask are among the first eight most loved and most wanted Web frameworks. Python is convenient for beginners, professional programmers, as well as the experts from other fields like mathematicians and non-computer-science engineers. It’s widely used by startups, academia, as well as large companies and platforms like Google, Dropbox, Facebook, Instagram, Quora, Reddit, Spotify, Netflix, Uber, Pinterest, Mozilla, Intel, and more.

3. Python Has a Friendly and Devoted Community

Many people work on the development of the Python and the third-party libraries. Many programmers write blogs related to Python.

If you have a problem when programming in Python, likely it’s already asked and solved by someone in this large community. Just search with your favorite search engine, and the chances are that you’ll find the answer on StackOverflow or a similar platform, or some of the blogs. You can also commit your question to StackOverflow, and you’ll probably get a quick response.

Python is changing all the time and becomes more sophisticated, faster, and able to respond to the challenges of today and tomorrow. Python Enhancement Proposals (PEP) is where the proposals for the improvements are announced. It’s crucial for everyone with long-term involvement in Python.

Finally, there is a set of recommendations or core values, called the Zen of Python, written by Tim Peters that represents the guiding principles for Python development. You can always get it with the command import this:

>>> import 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!

These principles are beneficial when working with Python, but you might find some of them generally enlightening.

4. Python Has Elegant and Concise Syntax

Python is designed to be readable. Its syntax is closer to the natural language or pseudo-code compared to the syntax of C-like languages. It uses whitespace: newline to end statements (we can use the semicolon, although it’s rare) and horizontal spaces or tabs to mark code block. This is an example of the if statement:

if x < 0:
    print('x is negative')
elif x >> 0:
   print('x is positive')
else:
   print('x is zero')
This is how the while loop looks like:
i = 0
while i < 10:
    print(i)
    i += 1
This is the for loop:
for i in range(10):
    print(i)

This is an example of how Python handles exceptions:

try:
    f(x, y)
except TypeError as e:
    print(e)
else:
    g(x, y)
finally:
    clean()

There are many convenient code constructs like the ternary if-else operator: x = y if condition else z.

5. Python Is Multi-Platform

Python interpreter works on many operating systems. In most cases, you aren’t going to notice the distinctions between the operating systems when programming in Python, except for the file paths. There are, however, some subtle differences. Many third-party libraries also work well on Linux, Windows, and Mac OS.

6. Python Supports Multiple Programming Paradigms

Python is a multi-paradigm programming language. It supports several paradigms like procedural, object-oriented, and functional. It has the built-in package functions that facilitates functional programming. Python also enables you to mix programming paradigms intuitively. You need to find the path that suits you the best.

7. Python Offers Useful Built-In Libraries

Whether you want to perform unit tests, enable multiprocessing capabilities, work with regular expressions, manipulate dates and times, generate pseudo-random numbers, or do some math or statistical calculations, Python offers useful built-in libraries. And many more. Python built-in libraries are well-tested and reliable. They are open-source, so you can go to GitHub and see the implementations.

8. Python Has Many Third-Party Packages

Although there are built-in libraries, they can’t cover all that programmers need. Python programmers have developed tons of free and open-source libraries you can get. You can find many of them via the Python Package Index (PyPI), the repository of Python software.

Python provides the default package installer called PIP. You can use it to conveniently download, install, update, and delete packages, manage virtual environments, and so on.

Anaconda is a third-party Python ecosystem. It provides Python, package manager called Conda, as well as many third-party libraries like NumPy, SciPy, Matplotlib, Flask, and so on. Conda can be used to download, install, update and delete packages, as well as to manage virtual environments. It excels in managing dependencies between libraries. With Anaconda, you also install the integrated development environments like Spyder, Jupyter Notebooks, and Jupyter Labs.

NumPy is a fundamental library to manipulate arrays efficiently. It brings a great performance boost and even more concise code compared to pure Python. SciPy is built on top of NumPy and contains many functions and classes for mathematics, statistics, and scientific computing. Pandas also relies on NumPy and allows very convenient handling of labeled one- and two-dimensional datasets. Matplotlib and Bokeh are great to viusalize data.

Scikit-learn is one of the main machine learning packages generally. It supports many methods and algorithms. It’s also built on top of NumPy. StatsModels is the library for advances statistics and can also be applied for machine learning. Tensorflow, Theano, PyTorch, Kears, and others can be used for neural networks. BeautifulSoup is used to extract data from Web sites. NLTK (natural language toolkit) is one of the most popular tools for natural language processing.

Python has several frameworks for Web development. The most popular is Django. It’s a comprehensive framework that follows the “batteries included” approach. You can build a large web application with a lot of usual functionalities really quickly with Django. Flask is another Python Web framework. It’s a micro-framework with many external extensions. It’s easier for smaller applications. You can get a working Web app in just a few lines of code. There are other frameworks as well: Pyramid, Bottle, Web2py, CherryPy, Tornado, and so on.

You can use Tkinter or PyQt to build desktop applications, Kivy for android apps, as well as many other libraries for all kinds of jobs.

9. Python Is a General-Purpose Programming Language

Python is useful for a variety of applications like data science and machine learning, Web development, Internet of Things devices, desktop and mobile applications development, and just automating repetitive tasks. This is due to the simplicity and flexibility of the language and interpreter. Also, due to the existence of a large number of third-party open-source libraries.

10. Python Plays Nice with Others

Python can be slow in some situations. However, if that’s the case, the chances are that you’ll find a suitable library written in C or C++, or maybe Fortran with a Python wrapper that’s very fast.

You can also create Python routines in C. Python is written in C and is very convenient for being extended with C (of course if you’re familiar with it). Cython is a static compiler and programming language that offers some additional functionalities to pure Python. It’s used to write fast code in Python-like style and combine Python flexibility with the power of C.

You can also combine Python with other frameworks and programming languages like .Net or Rust.

Conclusion

This article explains some of the most important factors that make Python so useful and popular. Whether you’re interested in data science, machine learning, web development, desktop applications, mobile apps, scientific computing, or just automating stuff, Python is worth considering.

Thank you for reading.

This article was provided by our teammate Mirko.