Thursday, November 16, 2017

Learning the Python Programming Language

As I had mentioned in my previous post, Raspberry Pi and Minecraft Pi My Oh My!, the version of Minecraft that came pre-installed on my Raspberry Pi 3 was very rudimentary and in order to do some basic functions, like getting a TNT block to explode, you actually need to know how to do some basic programming. For my son, not being able to explode TNT was a major deal breaker, so... as I always tell him, quitting is not an option...

Where to go to learn Python? The first place I went to begin my Python crash course was Codecademy. I chose Codecademy for a few reasons. One, it is free. You can create a basic account and take, what is essentially a full course. If you upgrade to the paid version, it gives you access to multiple choice questions and projects. Another reason I chose Codecademy is that you do not have to download anything (we will get to that soon), it is all internet based.

(Hint: If you have trouble completing a Codecademy assignment, Google the lesson name and you can usually find discussion boards on how to get the correct answer/code.)


I had no preconceived notion that I would be an expert at Python once finishing the free Codecademy course but rather a very introductory view of it. I'd imagine it would take years of courses, training, and practice to become a "Pro". Now that I had a basic understanding of Python and some of its capabilities, it was time to accelerate my learning. I did a lot of research on the Internet to try and find additional resources and one resource I kept stumbling across was Reddit. Reddit is a large community of users that discuss various topics, ask and answer questions, and post content. I quickly found a Python Reddit, a Raspberry Pi Reddit, and even a LearnPython Reddit. I posted a question, "What are best tools/courses/etc. for learning Python?" and almost instantly I started getting responses. I kept seeing responses for ATBS but had no idea what it meant. I Googled "ATBS Python" and sure enough, I found it! Automate The Boring Stuff.


(I fell in love with the Reddit Community after this experience. A lot of friendly helpful people there!)


Automate the Boring Stuff with Python is a book written by Al Sweigart. It is free to read on his website. " On his site, Al says, "In Automate the Boring Stuff with Python, you'll learn how to use Python to write programs that do in minutes what would take you hours to do by hand-no prior programming experience required." There are also links to his YouTube video lessons on his website that will help you work through the material in his book. One important distinction to mention: the free videos on his website and YouTube are not the full course! If you want the entire course in video format you need to purchase the $10 course on Udemy. This is what I signed up for. It has over 50 videos, recorded by the author of the book, with full lifetime access.

You'll remember in Codecademy, there was nothing to download. They have created an environment that allows you to learn/code on their website without actually downloading the Python. Going forward however, you will want/need to have Python on your computer/Raspberry Pi. The ATBS website will give you clear instructions on how to download Python and the ATBS Udemy.com course will provide you with a video tutorial on how to download. Once downloaded, you can begin the ATBS coursework and do Python coding on your own computer. Some computers may already have Python installed (my Raspberry Pi 3 with the Raspbian OS did). This is how you can check. At this point I will assume you have downloaded Python and have a basic understanding of how to use it. 


Now back to what got us into this "mess", Minecraft Pi. RaspberryPi.org actually has a very good guide called "Getting Started with Minecraft Pi". The guide will walk you through how to access Minecraft Pi and create a world. It will teach you how to use the Python programming environment IDLE to connect to Minecraft Pi. Python IDLE is an application that comes as part of the original Python download that we discussed in the previous paragraph. You enter all your code into Python IDLE for it to be executed in Minecraft Pi. As you continue through the guide, you will learn how to use the Minecraft Python API to post text to the chat window, find the player's coordinates within the world, teleport, build structures, and last but definitely not least..... Playing with TNT blocks! 

While my son is still learning to read and write the Alphabet in Kindergarten, he is learning to read and write in Python at home. (We do that boring Alphabet stuff at home too.) He can locate his player's coordinates and teleport him to somewhere else in world of his choosing. He can build large structures much faster using Python rather than the actual guy (Steve) in the game can. It is pretty incredible what he has been able to learn in a few short months. As long as he is having fun (while secretly learning amazing tools!) I don't see the harm in letting him "play" Minecraft Pi. 

During all this learning, under the guise of helping my son with his game, I have become very interested in Python programming, Raspberry Pi's, and Artificial Intelligence. I am active in the Reddit community, trying to absorb and learn as much as I can. Just wait until you see the next project we just finished, the Google Voice Kit!

Next Post: Google Voice Kit - AIY Project


1 comment:

  1. Thanks man for superior papers and sharing your journey of learning the python language. And it was really great of you for encouraging you son for not giving up even if it was a game. I believe that many will be learning from your experience and insight as i did. thanks for sharing.

    ReplyDelete