When a light source like a star is traveling sufficiently fast away from an observer, that star's light is red-shifted such that the perceived color is lower on the spectrum than the actual color emitted by the source, e.g., yellow goes to red, red goes to Infrared. Similarly, if a light source is traveling sufficiently fast towards an observer, that star's light is blue-shifted such that the perceived color is higher on the spectrum than the actual color emitted by the source, e.g., yellow goes to green, blue goes to Ultraviolet
Write and document a Python script convert.py which takes as command-line arguments a shift type in {red, blue} and the name of a single-column file of colors (one color per line) and outputs (1) for each color, the shifted color and, at the end, (2) the total number of shifts done as well as the total number of shifts into Infrared and Ultraviolet. Your script must work on datafile shift1.dat to produce the output given in typescript-file shift.script. You may assume that all colors in a given file are valid.
In Q2, you may find the math function sqrt() of use.
######################################################### ## CS 2500 (Fall 2009), Assignment #2, Question #1 ## ## Script File Name: convert.py ## ## Student Name: Todd Wareham ## ## Login Name: harold ## ## MUN #: 8008765 ## #########################################################You do not have to develop your code on our CS departmental systems. However, as your code will be interpreted and tested on our CS departmental systems as part of the assignment marking process, you should ensure that your code interprets and runs correctly on at least one of these systems.
Created: August 19, 2009
Last Modified: August 19, 2009