In this module, the self-study material focus on the fundamentals of programming. While this course is not a programming course, we will explore the necessary basics to get started such as state and code management. We will motivate the choice of Python for this course, and introduce a few specifics to Python. Finally, we will introduce the concept of Version Control Systems and code library, necessary step to use code from others and collaborate.



Python

Reading (30 minutes)

In the first assignment, we installed Python to use the Python package python-kasa to interact with the light bulb of our prototyping kit. Let’s go back a few steps.

What is Python?

Python is an interpreted, high-level and general-purpose programming language (Wikipedia).

Python is a programming language. Similarly to a natural language such as English, it defines a set of rules on how to tell machines what we want them to do.

Why do we use Python?

Because it was invented by the Dutch Guido van Rossum. No, well yes, it is a Dutch design but this is not the reason we use it in this course! Its relevance comes from a global community across disciplines (from mathematics to data science, artificial intelligence and automation) and its acknowledge ease to get started in contrast with other programming languages. These characteristics help us understand the relevance of Python in this course. To prototype a connected product, we need

Store and Manipulate Information

In programming, what we want to achieve is to store and manipulate information. We aim to provide you with a dry overview of the fundamental programming concepts so that we can quickly switch to hands-on practice with a shared understanding.

In programming, a variable is a storage location paired with an associated symbolic name. Each of the variables holds a value that either static or that varies throughout the program.

Variable

What information can we store? We can store any information. However, it needs to be of a certain data types. Two common examples are numerical (integers, floats, complex) and textual information. In programming, we refer to textual information as strings, a short for strings (or sequences) of characters. In contrast with other languages, you will notice that in Python you do not specify data types. Python infers automatically the type of information.

So why do types matter if Python takes care of it? Depending on the type of information we deal with, we will not do the same thing. For instance, with numerical information we want to make mathematical operations. In contrast, with textual information we want to put them together to form sentences.

Storing, comparing, showing on the screen, combining: these are all examples of information manipulation. In programming, we refer to statement for each line of code that manipulates information as it influences or relies on the state of a variable (i.e. stored information). Throughout the course, we will introduce statements with the Python syntax. You will recognise two types of statements:

if light is off
then turn on the light
else turn off the light

Notice: the examples above are not written Python. They describe the steps of an algorithm with plain language. This is called pseudocode.

Finally, what is not a statement in your code is a comment: information for the reader of your code which is ignored by the machine. It is critical for others to understand why you wrote your code in this way, but also for yourself when you come back to your code.

Version Control System

Reading and watching (45 minutes)

Prototyping connected products introduces a set of development challenges. The purpose of learning the basics of programming in this context is to help you collaborate on the design and development of a wide range of connected products. The design and development of these products is becoming increasingly agile: a never-ending set of iteration mixing design, implementation and evaluation that requires a common understanding for effective team collaboration. For instance,

These are some of the motivation to introduce a Version Control System (VCS). In this course, we will focus on Git, which you already installed in the first module.

Disclaimer: it has been scientifically proven that the mental model of git reflects the system’s perspective rather than the user’s perspective. A bad thing to do, isn’t it? Pardon the poor computer scientists and please take on the task of making it better!

In the following video, Alice Bartlett gives us an ‘as human as possible’ introduction ride through the main concepts of Git.

The following video illustrates the purpose of GitHub, a web service offering a Git remote as well as a set of collaborative and social features.

Quiz

Check your understanding with the following quiz! It is anonymous and you can try as many times as you want!

#2 Code
Prototyping Connected Product - Module 2

Shaping with code
Prototyping Connected Product - Assignment 2

TU Delft IoT Rapid-Proto Labs Erasmus +

The European Commission's support for the production of this publication does not constitute an endorsement of the contents, which reflect the views only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.