How (and Why) to learn Python with a Raspberry Pi

Author: Darhan Saami

Introduction

While surely Raspberry Pi sounds like a refreshingly sweet snack to have in the middle of your day, it offers a lot more purpose than just being something you could eat. Raspberry Pi is best described as a small computer. It is so small that it does not exceed the area of a pack of cards, making it portable and convenient. Raspberry Pi ranges around 35$, which is an affordable package for people keen to learn programming languages. At such a price, Raspberry Pi offers much more applications than just learning how to code. Raspberry Pi is commonly used to develop sophisticated control systems. It is a customizable device that could serve your many requirements. Once you own a Raspberry Pi, all you need to do is connect a keyboard, mouse, and screen to your Raspberry Pi, and you are good to go!

Why Python?

Raspberry Pi is a product of the Raspberry Pi Foundation, a charity organization in the UK. They have made these computers affordable to provide young individuals an opportunity to learn programming, among other skills. Since this device is tailor-made for learning programming, perhaps the simplest language to start from is Python. It is not only excellent for beginners but also complex enough to complete larger projects by experts. Python offers a human-friendly interface and readability, making it quite easy to learn and understand. Another added feature of specifically learning Python on a Raspberry Pi is that it contains a standard library of pre-built code, commands, and sub-routines. Raspberry Pi is ideal for Python as you get a fully installed Python package without much configuration.


While Raspberry Pi offers a wide range of languages you could work with, such as HTML 5, Javascript, C, C++, Python is the most standardized language to operate on your Raspberry Pi default. Raspberry Pi has an in-built GUI Interface and uses an IDE called Thonny; a Python Integrated Development Environment designed for beginners. Thonny is also in-built in Raspberry Pi by default; however, Raspberry Pi allows you to use other IDE’s if you want.

Why learn Python on Raspberry Pi? 


There are many reasons why Python and Raspberry Pi are so compatible with one another. Python is an easy to understand language on a beginner level, making it easier to learn than other languages. Python shares this trait with Raspberry Pi, an affordable tool designed for people keen to learn and experiment with simple DIY activities. Many programmers switch languages as they progress to advanced levels, but Python remains highly scalable for more extensive projects too. Many programmers choose to design even advanced programs using Python. The same can applies to Raspberry Pi. It sure seems like a micro version of a computer, designed to complete basic tasks by beginners, but there is a lot more to it than that. Raspberry Pi’s potential expands as we delve deeper into the possibilities of things we can do with a Raspberry Pi. For starters, Raspberry Pi is commonly used to make weather forecasts using its sensors, set up and design household security camera networks, home automation controllers, baby monitors, or even industrial applications. For both Python and Raspberry Pi, the potential for the number of things one could do only seems to grow. 


Raspberry Pi is incorporated with Python 2, the older but more commonly used version of Python, and Python 3, the newer and more adaptive Python version. Some IDE’s only have one version of Python installed, either not compatible with certain projects or have other limitations. This is not a problem in Raspberry Pi because it is already pre-installed with both versions of Python, making it easy to configure. 


Python is an inexpensive language to learn. You can indeed question the metrics I have used to call learning a language inexpensive; Python sure is perhaps the most common and widely used programming language out there. Such popularity gives it an added benefit of having plenty of free and non-pirated resources for people to self learn Python. Learning a language from scratch (not the language) is not as easy either. It requires some amount of dedication to persist through a completely different discipline. Python is a highly user-friendly language. The availability of complete resources removes much of the barriers to learning programming, making it highly accessible and, hence, use of the word ‘inexpensive.’ The same could be said for Raspberry Pi quite literally. Priced at around 35$, it does not get any better than that. A relatively powerful microcomputer at such a price is a steal. The device’s relative inexpensiveness makes learning Python more convenient for people who cannot yet afford a fancier computer. Much of Raspberry Pi’s practical applications are embedded upon coding, therefore owning a Raspberry Pi automatically adds an incentive to learn to program. Python is the default language of Raspberry Pi, which backs our argument even more. For more advanced projects, Raspberry Pi could require certain accessories such as sensors, cameras, etc. Investing in such equipment is expensive and often an impediment. One might allocate their resources to other requirements if they have saved up on a Raspberry Pi. 

How to launch Python on my Raspberry Pi?

You can launch Python on your Raspberry Pi by following the procedures below:

  • Connect your Raspberry Pi with a keyboard, mouse, and screen.
  • Complete all other connections and boot it up.
  • Find the start menu icon on the top left of your screen, click on it and then find ‘programming.’ Now, hold your cursor over ‘programming’ and wait. A new pop up window will open.
  • In programming, go to Thonny Python IDE and click on it.
  • A white blank screen will open up in front of you where you will type out your code. 
  • Go to File and click New File and save it by any name of your choice with the extension .py, which is standardized for all python files.
  • Write up your code. Once you have done that, you can click on the green play icon above to run the code. It is important that you also click on the red stop icon after you have executed the code. 

Raspberry Pi uses the Raspbian Operating System, which is a Linus based OS. Raspbian already has an in-built Python IDE, language, and command library so that you do not need to link it up with external libraries. In this blog, we will not teach pieces of code that one could execute. It is an extensive subject beyond the scope of this blog. Unfortunately, you will have to seek other resources to learn the programming aspect of Raspberry Pi. Instead, our goal is to explain why Python and Raspberry Pi go hand in hand. 

Why should I choose a Raspberry Pi over Arduino? 

The closest competitor for Raspberry Pi (in this case) is Arduino. A comparison between them is necessary to make a final purchasing and learning decision.

Raspberry Pi is far more suited to software applications than its counterpart, making it more suited to the Python environment. There are many similarities and differences between the two devices. Raspberry Pi has much greater memory and clock speed than an Arduino, offering Ethernet capabilities and multi USB peripherals. Arduino and Raspberry Pi were both developed as learning tools, so they have become so successful now. The primary difference between the two is that Raspberry Pi is a computer while Arduino is just a microcontroller. Hence, Raspberry Pi comes with a Linux distributions Operating System, while Arduino does not require one. Arduino has its language, while Raspberry Pi has several in-built languages, including Python, which we have already established as a very flexible language. Raspberry Pi even has a large memory, requiring it to be shut down after use, unlike Arduino, which powers off when used. While Raspberry Pi sounds like a far better product in terms of specifications, Arduino’s simplicity is a key feature that has made it so popular.

Arduino is slightly less expensive compared to Raspberry Pi. Although they are both priced at very reasonable levels, the price differential does not make much difference. However, it is clear that for the purpose we intend to achieve – getting to learn Python – Raspberry Pi is the better option to choose between itself and Arduino.

Conclusion

Raspberry Pi is a fascinating device that serves multiple purposes. Perhaps one of the standout features of it is the expanding number of things one could do with such a small device. There was never any question over its compatibility with Python since Python is Raspberry Pi’s default language. However, we have discovered how Raspberry Pi provides an exceptional learning environment for beginners too. We recommend Raspberry Pi to learn Python or other programming languages. With a Raspberry Pi, there are exciting things one could continue doing once they have mastered the language. It is easy to set up and get started in your quest to learn Python on a Raspberry Pi. 

You can purchase a Raspberry Pi here.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

2 thoughts on “How (and Why) to learn Python with a Raspberry Pi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: