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.

  1. 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.
    1. Given:
      • values is a sequence with at least one value.
    2. Initialize gMean to 1.
    3. For each value i :
          Set gMean to be the product of gMean and value i .
    4. Return the nth root of gMean.

    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:

  2. 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.
    1. Given:
      • values is a sequence with at least one value.
    2. Initialize mean to be the average of values.
    3. Initialize discriminant to be 0.
    4. For each valuei :
          Set discriminant to be the sum of discriminant and (valuei - mean)2 .
    5. Set discriminant to be discriminant / n
    6. 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.

  3. 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.

  4. Write a program that creates a greeting card, such as a Get-well Card, a Mother's Day card, etc. The program must use functions to do all the drawing, and each function should only draw one part of the card. E.g., if you were creating a Mother's Day card that said "To my mommy" at the top, had a picture (that your code draws) of your mommy in the middle, and a "Roses are red, violets are blue" poem at the bottom, y ou should write (at least) three functions to do this. Then, your code at the bottom of the file, the "main" code, would create a turtle object with which to draw, and call those three functions, passing in that turtle object to each function, where it would be used to do the drawing.

    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.

Checking In

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: