Reader small image

You're reading from  Getting Started with Raspberry Pi Zero

Product typeBook
Published inMar 2016
Reading LevelIntermediate
Publisher
ISBN-139781786469465
Edition1st Edition
Languages
Right arrow
Author (1)
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

Right arrow

Basic programming constructs on Raspberry Pi Zero


Now that you know how to enter and run a simple Python program on Raspberry Pi Zero, let's look at some more complex programming tools. Specifically, we'll cover what to do when we want to determine the instructions to execute and how to loop our code to do that more than once. I'll give a brief introduction on how to use libraries in the Python version 2.7 code and how to organize statements into functions. Finally, we'll very briefly cover object-oriented code organization.

Note

Indentation in Python is very important; it will specify which group of statements is associated with a given loop or decision set, so watch your indentation carefully.

The if statement

As you have seen in previous examples, your programs normally start by executing the first line of code and then continue with the following lines until the program runs out of code. But, what if you want to decide between two different courses of action? We can do this in Python using...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Getting Started with Raspberry Pi Zero
Published in: Mar 2016Publisher: ISBN-13: 9781786469465

Author (1)

author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett