Tuesday, August 1, 2017

Learn Python

We are back from our annual holliday, and hollidays are special for us. Three weeks a year without friends, relatives and obligations. We do not plan where we go to, we just put all our stuff in our car and drive south. And each year we end up in a different part of France which is beautifull.

Three weeks without newspapers, magazines, television, radio, computers, internet and even our smart-phones are put off.

We are totally incommunicado, and we love it. We love camping, read a lot, walk for miles, visit historical villages and nature sites, eat in local restaurants and just have the time of our lives.

Only this year I sinned a bit: I took my Android Tablet with me. And a computer book !!!

The reason for this was that I have several Raspberry Pi's at home. They are being used as a Domotics system, an IP camera, a Media Station and a printer server. None of these are projects I devellopped myself. I just download the code and use it.

However I wanted to learn to use the Raspberry for my own projects. Especially the humble Pi-Zero which just costs 6 euro would be an excellent starting point. It is a full fledged Linux computer with I/O ports. Ideal for IOT projects.
Where to start.

Python

Python is a versatile programming language that is fully supported by the Raspberry. In the Raspberry Operating System: Raspbian (a spacial branch of Debian linux) Python 2.7 and 3 are incorporated as well as the Geany programming editor.

Python supports the Raspberry's I/O ports and has a library for the special raspberry camera. So the easiest way to start projects with a Raspberry would be by programming in Python.

Few years ago I wrote a G-Code interpreter (for 3D printing) in Python and a program that displayed Google Maps on a PC screen.

So I had some experience with Python on my Desktop PC but never really got a good grip on it. I searched for functions on the internet and stumbled on things by accident. That allowed me to write programs and see how wonderfull Python is. However I never really learned it the right way.

Python on an Android Tablet




Yes, indeed. There is a Python interpreter readily available for Android. Just download it from the Google Play store (it's free) and start programming.
You can find it here: https://play.google.com/store/apps/details?id=org.qpython.qpy3

Learning Python

So I wanted a thorough course in Python programming. And a few weeks before my holliday I bought the following book:




Sams Teach Yourself Python Programming for Raspberry Pi in 24 hours.

And I did !!!
I really learned to understand Python programming in 24 hour.

If you have no real structured experience in Python and, like me, have just been messing around, searching things on the internet, this book is just great.

There are 24 chapters. Each chapter is a lesson full with demo programs and excercises that can be done within an hour. Hence the name. Every evening when my girlfriend went to bed I spend an hour studying Python and I learned a lot !!

You learn Python from the beginning working with variables, strings and artithmetics. Then it goes on with loops.
You learn about the different types of arrays that are called Tuples, Lists and Dictionaries. You will learn about writing your own functions and using libraries and modules. And also about GUI programming and Game programming.

The book will teach you how to use internet functions like writing a mail program, parsing HTML pages and using web-sockets.

And last but not least important you will learn how to write your own web-server and how to use the Raspberry I/O pins. This last part makes it very interesting to use the Raspberry Pi for IOT projects.

Practicing

I had no Raspberry Pi with me on my holliday (my girlfriend would shoot me). However I was able to follow most of the lessons on the Android Tablet.
I learned a lot during these 3 weeks especially about structuring my programs and about the different array structures. Every evening I was sitting in my tent and followed one lesson

The book is also full of tricks and tips that you can otherwise only find by hours searching on the internet.

I do not allow advertisements on this web-log and I do not normally promote / plug products. This book has learned me a lot in a short time and that is why I want to mention it to you.

Highly Recommended

Now I want one of these:

https://pi-top.com/products/pi-top

Till next time.
Have fun

Luc Volders