CSCI 299 / CITA 284 – Spring 2025 – Homework 1

Assigned Date: Monday, Feb. 3
Due Date: 11:00am, Wednesday, Feb. 12 (30 mins before class)

Introduction

The Golden Ratio, also known as the golden mean, the golden proportion, or the divine proportion, is a ratio between two numbers that equals approximately 1.618033988… (or 0.618033988…). Written as the Greek letter phi (φ), it is encountered in many places in Nature, and it usually associated with things or phenomena that humans find beautiful, well-balanced, or aesthetic.  For more information, see here and here.  Also, see this Walt Disney intro video (very nice).

According to Mario Livio,

“[s]ome of the greatest mathematical minds of all ages, from Pythagoras and Euclid in ancient Greece, through the medieval Italian mathematician Leonardo of Pisa and the Renaissance astronomer Johannes Kepler, to present-day scientific figures such as Oxford physicist Roger Penrose, have spent endless hours over this simple ratio and its properties. … Biologists, artists, musicians, historians, architects, psychologists, and even mystics have pondered and debated the basis of its ubiquity and appeal. In fact, it is probably fair to say that the Golden Ratio has inspired thinkers of all disciplines like no other number in the history of mathematics.” [1]

The Golden Ratio is connected with the Fibonacci sequence, i.e., 1, 1, 2, 3, 5, 8, and so on, which is defined by adding two consecutive numbers to get the next one.  If instead of adding, you divide the two numbers, the result approximates the Golden Ratio (the further you go into the Fibonacci sequence, the more accurate the Golden Ratio approximation becomes).

Assignment

Write a well-documented Python program that draws the Golden Spiral, using the approach we have identified in class.

In particular, break up your process into three parts.  I should be able to see which part is doing what, through your documentation / comments:

  1. Draw points on the Golden Spiral, using the Point class in JythonMusic, as demonstrated in class.
  2. Draw the enclosing squares, using the Rectangle class in JythonMusic, as in Figure 1.
  3. Finally, draw the Golden Spiral, using the Arc class in JythonMusic.

NOTES:

  1. The program should have a variable howMany at the top of the code to identify how many points, squares, and arcs to draw.
  2. The origin (i.e., original point) should be at the center of the Display.
  3. Do not use the following figure in your final program.  You may use it as a guide, while you are developing.  However, the final submission should be generating everything using primitives, namely Point, Rectangle, and Arc.

 


Truth and Myth in the Golden Ratio - Fibonacci Lifechart

Figure 1.  A Nautilus shell superimposed with Fibonacci squares, and the Golden Spiral. 


Program Documentation

You goal is to create very readable code.

The Golden Rule of Style:  “A program should be as easy for a human being to read and understand as it is for a computer to execute.” [1]

Your program should be written using best programming practices, and be commented fully, as per class guidelines.  You should comment all variables, obscure statements, and blocks of code.

Remember, comment first, translate to Python second – like I did in class.  The quality of your comments will be much, much better.

Header Documentation

VERY IMPORTANT:  Copy and paste the following to the top of your program.

# nameOfYourProgram-MakeSureYouUpdateThis.py
#
# Author:  Your full name
# Email:   Your school email 
# Class:   CITA / CSCI 284   
# Assignment: Homework #1
# Due Date:  The due date 
#
# Purpose: Describe what the program does.
#
# Include any special notes, such as URLs of background information or sources (very important).
#

Update the “Purpose” portion, to explain what your program does.  Look at the book examples here, to see how to do this well.

Give your program a meaningful name.  For this assignment, name it drawGoldenSpiral.py.

Your grade will depend on the accuracy of your result, and on how well you did the coding and documenting part.

Submissions

1. Bring to class the following:

  1. A printout of your Python program.  I should be able to read and comment on your code.
  2. A printout (screenshot) of your program’s graphical output.
  3. Staple them together – in that order.
  4. Be ready to demonstrate, and talk about your program in class.

2. Submit your Python (.py) file on OAKS, so I can run it on my computer – with all the necessary data, image files, etc. – if any.  Do not zip your submission – this adds an extra, unnecessary step in grading.  Thanks!

Grading

Your grade will be based on how well you followed the above instructions, and the depth/quality of your work.

Reference

  1. Livio, M (2002). “The Golden Ratio: The Story of Phi, the World’s Most Astonishing Number“, Broadway Books, New York, p. 6 (see here).
  2. Cooper, D. and Clancy, M. (1985) “Oh! Pascal”, 2nd ed., W.W. Norton & Company, New York, p. 42.
Skip to toolbar