Introduction
Python is a very easy to use language, which is why I like to use it to develop programs for quick proofs of concept (for example, creating a simple server or opening a socket to communicate with a ESP8266).
One big advantage of Python is that there are lots of libraries and modules that offer us easy to use functionalities, a little bit like we have in Arduino.
To install Python, just go here, download the installer and run it (assuming that you are using Windows, if you are on Linux you can also easily install Python from the command line). The differences between versions 2.x and 3.x are explained here.
You can also run some Python code online here, to test the language before installing.
Python IDE
Python comes with a simple IDE called IDLE. After installing Python, search for IDLE and run it. You should see a window similar to the one in figure 1.

As seen, IDLE presents the Python shell by default, where you can send commands.
Hello World
As stated before, Python is a very easy to use programming language. So, to output the famous “Hello World” sentence, you can just type the following in IDLE, in the shell, and press enter:
print ("Hello World")
The string in quotes will be printed in IDLE’s command line, as shown in figure 2.

This is very simple compared to, for example, Java, where you would need to write something like:
System.out.println("Hello World");
Or in C, where you would have to write something like:
printf("Hello World");
Scripts
For more complex programs, it’s easier to write all the code in a file (or multiple files) and run it at once, instead of writing the commands one by one in the command line.
To do it in IDLE, we just go to File -> New File, as shown in figure 3.

In the new window, we just write our code and then click Run -> Run Module, as shown in figure 4.

For the print(“Hello World”) code, the same “Hello World” sentence should be printed in the shell of IDLE.
Libraries
One of the big advantages of Python is the big number of libraries/modules available that implement very different functionalities and are easy to install and use. Bellow, there’s a list of some interesting ones:
- OpenCV: Computer vision library;
- NumPy: Scientific computing library;
- ScyPy: A library for mathematics, science and engineering;
- Django: Web framework for rapid development;
- Bottle: Micro web framework;
- Flask: Micro web framework. Check this post for an example IoT application using it;
- Scrapy: Web crawling framework;
- Tkinter: A library for GUI design;
- SQLAlchemy: Object relational mapper for Python.
You can check some other useful modules here. There are plenty of libraries around the web, it’s just a matter of doing a quick search before starting to implement something from scratch, since it’s probable that someone has already created a library in Python for that.
In order to install new python libraries the easiest way is using pip, which is a very easy to use command line installer. Installing libraries with pip usually only requires a command like pip install libraryName.
Pingback: techtutorialsx
Pingback: techtutorialsx
Pingback: Python: Parsing JSON | techtutorialsx
Pingback: Python: Parsing JSON | techtutorialsx
Hi antepher! I love Python as well. Seems like your using an out of date version of Python. Upgrade to the latest version of Python 2 at python.org/getit. You can also get Python 3. Get it at python.org/getit. Cheers! Epic Chas Gamer 😀
Thanks for the reminder 🙂 I installed this version some time ago and I didn’t have the need to upgrade it yet, but I will check the improvements on the newer versions of Python 2. Cheers
Hi antepher! I love Python as well. Seems like your using an out of date version of Python. Upgrade to the latest version of Python 2 at python.org/getit. You can also get Python 3. Get it at python.org/getit. Cheers! Epic Chas Gamer 😀
Thanks for the reminder 🙂 I installed this version some time ago and I didn’t have the need to upgrade it yet, but I will check the improvements on the newer versions of Python 2. Cheers
Hi again antepher! Good luck with your blog! When I said you are using an out of date Python 2, I mean there is a mini update to Python 2: 2.7.9. I think it is just a bug fix update, but it is worth it. Cheers! Epic Chas Gamer 😎
Hi! Yes I’ve been checking some release notes of the latest versions and they have some improvements, I will update the Python version for my next posts 🙂 They already have a 2.7.12, released this year:
https://www.python.org/downloads/
Cheers
Hi! Yes I’ve been checking some release notes of the latest versions and they have some improvements, I will update the Python version for my next posts 🙂 They already have a 2.7.12, released this year:
https://www.python.org/downloads/
Cheers
Hi antepher, thanks for the great post. I’m looking at learning some basic Python in the near future and your information above will certainly be useful, especially your list of libraries. Thanks!
Thanks for your feedback 🙂 Python is a very powerful but simple to learn language, it’s a very good choice to learn it. I’m planning on doing some more tutorials soon, stay tuned.
Best regards
Hi antepher, thanks for the great post. I’m looking at learning some basic Python in the near future and your information above will certainly be useful, especially your list of libraries. Thanks!
Thanks for your feedback 🙂 Python is a very powerful but simple to learn language, it’s a very good choice to learn it. I’m planning on doing some more tutorials soon, stay tuned.
Best regards