PA Designer Learn 2: LED and Loudness Sensor

This is the second challenge within the Robotics with GoPiGo and Python Curriculum.

Your task is to program your robot to alert a person with a hearing impairment to visiting house guests.

Learn how to use the Loudness Sensor alongside Jupyter Notebooks.

10. Print

One line of the code does a lot of the work:

print (f"Loudness = {loudness.read()}")

loudness.read() is a loudness sensor class library function. It gives us a number that represents the loudness of the environment, as measured by the sensor. 

The print() function uses what is known as an f-string (or formatted string) as its argument. An f-string is identifiable by having an f before the quote marks. 

f-strings are different from normal strings in that they can contain variables or the results of function calls. These are marked by curly braces { }. In this case, reading from the loudness sensor {loudness.read()} is inserted directly into the string to be written into the notebook.