Analyzing Finch Data I

Find the maximum, minimum, and mean of your Finch data!

Free Teacher Materials

Get Access

ADVANCED: Going Further

Required lessons: Variables, Lists

Collect data from a Finch sensor for ten seconds and find the minimum, maximum, and mean values. Start by writing a program that takes 100 distance measurements with the Finch and stores them in a list named distanceMeasurements. The program should wait 0.1 seconds between measurements.

Next create a variable called max and set it equal to zero. Then go through your list and check if each value is larger than the current value of max. If it is, set max equal to that list value. If you do this for every value in the list, then at the end of your program, max will be equal to the largest value in the list!

Find the minimum value in your list using a similar method as you used to find the maximum. You will want to set your min variable equal to a number that is larger than any possible distance measurement at the beginning of the program.

Finally, calculate the mean of all your distance measurements. Create a variable named sum and add every measurement to this variable. Then you can divide by the number of measurements to get the mean!

At the end of the program, display your maximum, minimum, and mean values for the user.