With more than 10.1 million developers using Python, the popularity of the Python programming language cannot be denied. Since its first release in 1990, Python has gained public support in academia and business, and is widely used in artificial intelligence and machine learningserving as the substantiation of OpenStacklike powering the cloud file storage service Dropbox.
This extensibility makes Python an excellent programming language for juniors developers to start with, but also one that remains widely applicable, as Python is widely used for real-world applications. This cheat sheet explores what Python is used for and how it compares to other programming languages, and provides resources for language learning. This article is also available for download: Python Programming Language: A Cheat Sheet (Free PDF).
TO SEE: Hiring Kit: Python Developer (Tech Republic Premium)
What is the Python programming language and who created it?
Python is an interpreted programming language (also called a scripting language), created in 1990 by a Dutch programmer Guido van Rossum, after his experience working on the education-oriented ABC language at CWI. Python differs from other programming languages in that it prioritizes code readability and the use of white space over compact, small source files.
Python is dynamically typed and collected (via reference counting and cycle detection), fully supports object-oriented and structured programming, and largely supports functional and aspect-oriented programming, making it particularly versatile and applicable to a wide variety of use cases.
TO SEE: Python Eats the World: How a Developer Side Project Became the World’s Most Popular Programming Language (TechRepublic cover story PDF)
The standard library is widely regarded as one of Python’s greatest strengths; this feature allows programmers to quickly develop projects without relying heavily on third-party packages for the basic installation of a particular application. In addition to the standard library, the Python Package Index (PyPI) catalogs over 300,000 packages that provide various functions.
What is Python used for?
Python’s design as a language makes it a good choice for multi-author projects, as the language’s inherent readability aids in its ability to pick up code and clearly understand how it works. Python is a powerful programming language, allowing even junior developers to accomplish quite a bit – as is the case with practically everything in computer science, there’s an xkcd for that.
Python is currently one of the most popular programming languages for people to learn, widely desired for its machine learning (ML) and data science features. The language’s scikit-learn ML library saw an 11% increase in usage in 2020, while the PyTorch ML framework used for deep learning saw a 159% increase in usage. Python is also Microsoft’s most popular extension for Visual Studio Code, with support on Azure and an easy installation option from the Windows Store.
Python is widely used in artificial intelligence; Google’s TensorFlow framework includes Python modules, as well as Keras and Scikit-learn. Similarly, Facebook’s PyTorch is growing in popularity, with support on both AWS and Azure. For data scientists looking to prepare data for machine learning, the Anaconda project is a distribution of Python and R that is optimized for scientific computing, with a focus on numerical methods and statistical analysis. IBM’s Qiskit and D-Wave’s Ocean learning platforms also use Python for programming quantum computers. Other science-focused options include the popular NumPy, SciPy, and Matplotlib libraries.
Outside of scientific computing, Python continues to be popular for web development frameworks, including Django, CherryPy, Pyramid, Flash, web2py, and webapp2. Graphics editing programs also use inline Python scripting, including the 3D animation software Autodesk 3ds Max, Maya, and MotionBuilder, as well as Cinema 4D, Lightwave, Houdini, and modo, the Nuke composer, and the open-source Blender toolset. It is also used in trusted 2D graphics software, Like it PaintShop Pro, as well as the open-source software GIMP, Inkscape, and Scribus.
In addition, LibreOffice uses Python for inline scripting, much in the same way that Visual Basic is used to extend Microsoft Office features.
Why use Python instead of other languages?
In 1999, software developer Tim Peters, a major contributor to Python and creator of the original CPython implementation, wrote the “Zen of Python”, an explanation of Python’s design philosophy and the philosophy programmers should incorporate into their programming approach. The document was later included in the official Python documentation.
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.
Saving is better than close.
Special cases are not special enough to break the rules.
Although usability is better than purity.
Mistakes should never pass quietly.
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 may not be so obvious in the beginning, unless you are Dutch.
Now is better than never.
Though never is often better than Turn right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it can be a good idea.
Namespaces are a great idea – let’s do more of them!
How does Python compare to other programming languages?
While the CPython reference implementation is useful in most cases, other Python interpreters exist to meet specific needs and implementation scenarios. MicroPython is a microcontroller-focused implementation that supports Arm architectures, in addition to Arduino, ESP8266, ESP32, and RISC-V (32- and 64-bit) architectures, with a Raspberry Pi implementation for its Pico family of microcontroller boards and RP2040 chips. CircuitPython is an education-focused fork of MicroPython.
PyPy is the most popular alternative implementation of general purpose Python. It differs from CPython in that PyPy is a (faster) just-in-time compiler, while CPython is an interpreter.
Python is another alternative implementation of Python. Pyston 2.2, an open-source implementation of Python 3.8.8, promises to be 30% faster than the original implementation. CPython’s Pyston Fork 3.8.8 is available on GitHub.
Other language target implementations also exist, including CLPython for Common Lisp, IronPython for .NET/Mono, and Jython for Java. Likewise, the night project is a source-to-source compiler from Python to C/C++ source code.
Which version of Python should I use?
The Python 3.x series was introduced in December 2008 and resolved and corrected fundamental design flaws, as well as general modernization of the language. Python 3 was developed with the guiding principle of “[reducing] function duplication by removing old ways of doing things.” Because of this, Python 3 is not fully backwards compatible with Python 2, forcing developers to modernize their code to run on the new version.
Python 2.7 support ended on January 1, 2020. The latest releases of Python are versions 3.8.13, 3.9.13, and 3.10.5.
Python 3.11 is currently in beta, with beta 3 set to be released in early June 2022 and expected to be released in October 2022. Speeding up Python is a primary focus of the language’s core development team, with Van Rossum hoping to double the performance of CPython in version 3.11 as part of his work on Microsoft’s Developer Division. Python 3.11 is expected to be supported until the end of 2027.
How do I learn Python programming?
You don’t need a degree in computer science to learn Python – there is a wealth of resources available online to help users getting started with the programming language.
Google launched a Python training course, the Google IT Automation with Python Professional Certificateon Coursera.
TO SEE: Getting Started with Python: A List of Free Resources (Free PDF) (TechRepublic)
TechRepublic Academy, a joint venture between TechRepublic, ZDNet and StackCommerce, also offers a wide range of: in-depth Python training.
If you’re already familiar with programming, chances are your IDE of choice supports Python natively, or support can be added using a plugin. For new programmers, using a free IDE that supports Python is a quick way to get started, such as Atom, PyCharm, Geany, Sublime Text, and Visual Studio Code. Perhaps the most popular Python programming tool for beginners is the cross-platform Thonny, which also supports dialects such as MicroPython.
Many offer REPL (Read Evaluate Print Loop) tooling to help you try out new Python commands in your editor or browser. This approach also makes it easy to test new code as you write it, without leaving your chosen development environment. Other tools, such as Jupyter Notebooks, embed a Python interpreter in a shareable document. This allows you to share code with colleagues or provide an out-of-the-box interactive environment to experiment with machine learning or numerical analysis.