Python is one of the most popular programming languages in the world right now, as well as the first one many people learn. This fact is not an exception for me, and I plan on explaining all aspects I discover about this language. In this short post, I will explain what Python is and the first steps you need to take to start programming with it.
What is Python?
Python is a multipurpose language, which means we can use it for many different tasks: create applications, videogames, web pages and more. One of the most remarkable aspects of Python is that it is super easy to interpret by humans. Due to this, it is far easier to learn than other programming languages.
The Zen of Python
The Zen of Python is a list of principles developers follow to write simple, clean and quality programs. These principles are the following:
- 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
- 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 a great idea. Let's do more of those!
How to install Python IDLE
There are two different versions of Python: Python 2 and Python 3. I'm currently learning Python 3, so this is the version about which I will write.
To run the programs we created, we must have an IDLE (Integrated Developing Environment). We can use the terminal as an IDLE or install a specific program such as Thonny, the Python IDLE, Spyder or Visual Studio Code IDLE.
If you wish to install any of these, you can follow these links to their webpage:
- Python IDLE: Download the most recent version of Python 3 and install the .exe file.
- Visual Studio Code: This is also a text editor, which I will explain in the next section. You need to download and install this program.
- Thonny: At the top of the page, you will find the links to download Thonny for different systems. Choose yours and install it.
There are many more IDLEs out there, but these are the ones I have tried. I use Visual Studio Code since, as said, it can be used both as an IDLE and as a text editor. I sometimes also use Spyder.
We can open any IDLE by double clicking on it, and we will be ready to start writing our first program!
Code editors
A code editor is a text editor that recognizes the code that we write in it, depending on the extension we use to save the file. For example, if we open a file called helloWorld.py, the code editor will know that the language used is Python; and if we open an index.html, it will understand that we have used Html to write the code.
Apart from recognizing the language, it also uses different colours to show various parts of the code and helps us write it faster with auto-completion features.
It is recommended to write our code in a code editor and then run it using an IDLE.
The code editors I mainly use for Python are Visual Studio Code (which supports many more languages and version control) and Spyder (focused on Python). Both of them are great code editors.
You can download Visual Studio Code from this link, while Spyder is in the Anaconda Navigator (link HERE), which is very popular for data science and machine learning. It includes many different features you can use, including the Spyder IDLE and code editor.
These two code editors are great as they have an integrated IDLE, so you can write and run the code directly with them.
To sum up
Python is a very robust language to learn as we can use it for many different purposes and areas (data analysis, machine learning, web development and more).
In this post, we have learned the first steps we need to take to get into programming (that is, having the right tools to do so). I hope you have found it handy and happy coding!