CSSE 120 — Introduction to Software Development

Homework 10

Reminder: for each class session and associated homework:

  1. Complete the assigned reading for the next session: Zelle, chapter 8.
  2. (22 points) In Angel, complete the Reading Quiz over the above reading.
  3. Solo Programming: The remaining exercises are to be done in the 10-DecisionStructures project that you checked out in class. There's a lot here. My intention is to help you get back up to speed for the exam on Friday. The only real way to study for an exam in this class is to practice.
    1. (15 Points) Complete the exercise that you started in class in the countPassFail.py module, per the TODO's in the module.
    2. (40 points) Do the exercise in the circleOfCircles.py module, per the following instructions:

      Create a function called circleOfCircles that takes five parameters (as described below) and draws n circles whose centers are equally spaced around a (usually) larger circle, as in this example where n is 12:

      Sample display of the circleOfCircles function

      Note that, as the image shows, you do not actually draw the larger circle that the n circles are spaced around.

      The parameters must be as follows, in the order listed:

      • A GraphWin object onto which the function will draw the circles.
      • n, the number of circles to draw.
      • A Point that is the center of the “big” circle that the other circles surround.
      • The radius of the “big” circle.
      • The radius of each of the “small” circles that your function draws.

      Additional requirements:

      • If the entire “circle of circles” will not fit inside the GraphWin that it is given, the circleOfCircles function must print an appropriate message to the console instead of drawing the “circle of circles.”
        • Hint 1: use an IF statement!
        • Hint 2: you will want to use the getHeight and getWidth methods that a GraphWin has.
        • With this and the other additional requirements, the graphics window SHOULD appear — that's OK!
      • If the parameter n is not greater than 2, the circleOfCircles function must print an appropriate message to the console instead of drawing the “circle of circles.”
      • Optional (but easy): If the parameter n is not an integer, the circleOfCircles function should print an appropriate message to the console instead of drawing the “circle of circles.”
        • Hint: here is how to do this, where n is the variable being used for the parameter:
              if type(n) != int:
                  # Print the error message to the console
              elif:
                  # ...
          

      We supplied a displayOneCircleOfCircles that main calls to test your circleOfCircles function. The first test will display the example “circle of circles” shown above, if your implementation is correct. You must supply additional tests in main as appropriate.

      Finally, note that tracing out a circle is straightforward if you use polar coordinates. For an example of using polar coordinates, see the calculateVertices function in the pizzaPolyStar.py module.

    3. (20 Points - 5 each for the four functions that you write) Do the exercise in the mutantFunctions.py module, per the TODO's in the module.
    4. (20 points) Do the exercise in the numerology.py module, per the TODO's in the module.
  4. More Python culture: What's up with the shrubbery examples? Check out this visit of King Arthur to the Knights Who Say “Ni!”.