Data processing using lists

This example demonstrates how to create lists and do some simple processing of the data in the list. 

Equipment:

  • Dongle

First of all, a list in one of simplest and most important data structures in a programming language such as Blockly and Python.


A list is basically a collection of items, each item could for example be a numbers. The list collects the items sequentially in a data structures.

For example, in Blockly this is how you would write a list with the items 9, 43, -11 and assign the list to a variable called 'data'':

And this is how you would create the same list in Python:

data = [9, 43,-11]

 

The following example demonstrates how to first create a new empty list in blockly. It repeatedly measures the sound level and append the list with that measurement. The list will quickly grow longer and longer. At the same time it creates a plot where it selects the largest number from the list (the graph will grow every time a new record loud sound is measured). 



You can download (right click and choose save link as..) the blockly code from here.

 

Copyright 2018 Shape Robotics. All Rights Reserved.
This website uses cookies to remember your settings and statistics. More info
Got it!