Your instructor may assign one or more of the following problems. Don’t feel that you must do all the problems; for the homeworks, you are only required to do those that are explicitly assigned via Moodle.
When people talk about an average value, most often they are referring to the arithmetic mean (sum of the values, divided by the number of values). There are, however, other “measures of central tendency.” For example, the geometric mean of a sequence of n values is the nth root of the product of all the values. A simple algorithm to compute the geometric mean of a sequence of values is
Algorithm Let n
be the number of values in the sequence.
- Given:
values
is a sequence with at least one value.- Initialize
gMean
to 1.- For each
value i
:
SetgMean
to be the product ofgMean
andvalue i
.- Return the
n
th root ofgMean
.
Write a function that receive a list of values and computes the geometric mean of the given list. Test this function by using it to compute and display the geometric mean of data input by the user. Notes:
n
th root of a value x
you can use x**(1/n)
While a mean tells you something about the central tendency of your data, the standard deviation instead measures the amount of variability or diversity in your data.
To compute a complete population's standard deviation, you can use the following algorithm:
Algorithm Let n
be the number of values in the sequence.
- Given:
values
is a sequence with at least one value.- Initialize
mean
to be the average ofvalues
.- Initialize
discriminant
to be 0.- For each
valuei
:
Setdiscriminant
to be the sum ofdiscriminant
and(valuei - mean)2
.- Set
discriminant
to bediscriminant / n
- Return the square root of
discriminant
.
Write a function that receives a list of values and then computes the standard deviation of the given list. Test this function by using it to compute and display the standard deviation of data input by the user. Be sure to include appropriate documentation.
Write a function that draws a composite figure of some sort. Your instructor will specify one (or more) of the following examples.
The function should receive a turtle with which to draw, x and y coordinates and a scale factor, and then use the turtle to draw the figure in the specified location at the specified scale factor.
Create a program that defines your new function and demonstrates its use.
E.g., the format of your file should be:
For honors students: Your greeting card must have some animation in it. Do this with a while(True) loop that calls either one of multiple functions or calls the same function each time, passing in a different value each time.
Submit all appropriate files for grading, including code files, screen captures, supplemental files (e.g., image files), and text files. We will grade this exercise according to the following criteria: