Python is certainly one of the most widely used programming languages today. Thanks to its flexibility and a vast community of people, it is used in numerous companies worldwide for various purposes, allowing many developers to use it, despite different career paths.
In this article, we will explore what type of language Python is, and why and how it differs from many other programming languages.
We will then delve into the areas where Python is most commonly used, where to learn it, how to install it on our machines, and, finally, we will see how to write a simple program.
- What kind of language is Python and how does it differ from others?
- Programming in Python: What Can I Do?
- How and where to learn Python for free (or almost free)
- How to install Python on your PC
- How to install Python on Windows, macOS, and Linux
- How to install Anaconda on Windows, macOS, and Linux
- How to write a program in Python
- Start programming in Python!
What kind of language is Python and how does it differ from others?
Python is a programming language that was first developed in 1989 by Dutch computer scientist Guido van Rossum, who named it Python because he was a fan of the British TV series “Monthy Python’s Flying Circus”.
As reported by Wikipedia, “In 1999, Van Rossum submitted a proposal to the Defense Advanced Research Projects Agency called Computer Programming for Everybody, in which he further defined his goals for Python:
- An easy and intuitive language just as powerful as major competitors
- Open source, so anyone can contribute to its development
- Code that is as understandable as plain English
- Suitability for everyday tasks, allowing for short development times
In 2019, Python became the second most popular language on GitHub, the largest source code management website on the internet, second only to JavaScript.”
The main difference between Python and other major similar programming languages is that Python is an interpreted language, while most similar languages are compiled.
The difference between a compiled and interpreted language is that a compiled language is represented by a file already written in binary code, making it recognizable by a machine and, therefore, immediately executed.
Recommended article: Frontend Trends for 2024
In an interpreted language like Python, on the other hand, the program is represented by the source code and, each time it is launched, it is first translated and then compiled. While this represents the true strength of Python, making it a more user-friendly programming language, it is also somehow its Achilles’ heel because it can decrease machines’ performance, often making them too slow, and thus making Python unsuitable for applications where responsiveness is crucial.
Recommended read: Logging in Python, a gentle introduction.
Lastly, Python is a high-level programming language because it provides a high level of abstraction, making it easier to write code compared to low-level programming languages.
In other words, this means that developers can write Python code using concepts and constructs close to natural language, without worrying about low-level details, such as memory allocation or processor registers. This makes Python the perfect language for those who want to learn programming.
An example? If I want to write a variable “age” to indicate my age, I can write:
age = 33
In other programming languages, especially compiled ones, it wouldn’t be the same.
For example, to declare the same variable in C++, we would have to write it like this:
#include <iostream>
int main() {
int age = 33;
// other commands or operations
return 0;
}
Code language: PHP (php)
And here we can immediately see the simplicity of Python compared to a compiled programming language.
Programming in Python: What Can I Do?
So, what exactly can we do with Python?
The strength of Python relies on its flexibility and suitability for different types of problems and situations. In some cases, this flexibility is also its Achilles’ heel, as we mentioned before. But on the other hand, as is evident, there is no optimal tool to solve every problem: there are specific tools for specific problems, although general-purpose tools can provide a good level of problem-solving.
Anyway, let’s see the areas where Python is widely used with excellent results:
- Automation. Thanks to its flexibility and a vast community of developers creating numerous libraries and providing support, Python is the perfect language for automation. An example of automation? Let’s imagine having a folder with hundreds of files in different formats: images, PDF documents, Word documents, etc. With Python, we could write a program that reads the file extensions and puts them all in subfolders named “PDF,” “images,” etc.
- Back-End development. Although Python has some rivals in the Back-End domain, it is still a widely used language by many companies worldwide to develop the Back-End part of many web applications. In fact, Python has many frameworks in this regard. The most commonly used ones are “Flask” and “Django.”
- Data analysis, Machine Learning, and AI. Thanks to the multitude of libraries and frameworks, Python is the perfect language – and the most widely used one – for data analysis and Machine Learning. Libraries like `Pandas` are excellent for data analysis, and `scikit-learn` for Machine Learning. There are also various frameworks for Machine Learning and Deep Learning, such as `PyTorch` and `TensorFlow`.
How and where to learn Python for free (or almost free)
Given its flexibility and relative ease of writing, Python is definitely the perfect language to start learning programming.
Moreover, as it is used by many companies in various fields as we have seen, many people are willing to learn it. It can also be a good idea for a career change.
Today, there are several online solutions to learn Python for free (or almost free). Here are some links:
- “Learn Python” and “tutorials point” are two websites where you can learn Python for free, and they also offer some learning paths to follow. If you prefer videos, instead, you can refer to the “Python programming” website.
Of course, YouTube is also filled with free tutorials, but they often lack a structured learning path.
- “Medium”. Medium is a writing platform that has subscribing fee of $5/month and offers a lot of Python tutorials for everyone (both beginners and advanced) and covers various topics (automation, Back-End, Machine Learning, etc.).
- “Udemy”. Udemy is an excellent platform where you can find Python courses for all levels and various topics, for just a few tens of euros. It is great because it provides a structured path to follow from start to finish.
How to install Python on your PC
There are several ways to install Python on a PC. Let’s see a couple of them.
How to install Python on Windows, macOS, and Linux
To install Python on a Windows or macOS machine, simply visit this website, download the latest version, and install it like a regular program.
For Linux machines, we can either download the latest version from the above-mentioned website or use the terminal as follows:
$ sudo apt update
$ sudo apt install python3
Now, the “issue” with this approach is that it will only install Python on our machines. Once we become familiar with the programming language, however, when we need to use libraries that are not included in the standard installation, we’ll have to install them one by one.
To avoid this, one solution is to install Anaconda on our PC. This way, in addition to installing Python, we’ll also install all the commonly used libraries for data analysis and Machine Learning, as well as many libraries used in other domains.
How to install Anaconda on Windows, macOS, and Linux
For all three operating systems, to install Anaconda we can visit this link and download the package for the latest version.
How to write a program in Python
Earlier in this article, we wrote a Python program. Specifically, although the program doesn’t do anything special, it still does something important: it saves in memory that the value of the variable “age” is 33.
Now, just for the pleasure of seeing the simplicity of Python, let’s write a small program.
For example, let’s imagine we have a list of fruits. We want our program to consider all the fruits and print the phrase “I love <fruit>” with the name of each fruit.
We can do it like this:
# Create a list of fruits
fruits = ["banana", "apple", "pear"]
# Iterate over the list
for fruit in fruits:
# Print phrase
print(f"I love {fruit}")
>>>
I love banana
I love apple
I love pear
Code language: PHP (php)
So, in a very simple and intuitive way:
- We created a list “fruits” that contains the names of some fruits.
- We created an auxiliary variable “fruit” that, through the “for loop”, iterates over all the elements of the “fruits” list.
- Finally, we printed our sentence for all the elements of the list using the `print()` command.
Start programming in Python!
In this article, we have seen that Python is a programming language used in very diverse fields, ranging from Back End and Python for Microservices to Machine Learning.
Lastly, we have seen how, thanks to its simple syntax, we can write a program that is understandable even by non-experts in the development field.