CS8 Programming Assignment 5
DescriptionThis programming assignment is a practice on generating Python dictionaries and reading files. You will develop programs that read from a text file named stars.txt, and create and return a dictionary data structure, and then perform certain computations over this dictionary.
RequirementsI am providing a text file stars.txt containing 148 lines. Each line has the name of a star, such as Alnilam, followed up by its distance in light years to the Solar System, such as 1340, and its apparent visual magnitude (AVM), such as 1.70. AVM is a number which is a measure of a star's brightness; a smaller AVM indicates that the star is brighter. The star file is available here: stars.txt. For example, the line about the star Alnilam is as follows:
Alnilam 1340 1.7which is the the central star in Orion's belt. It is at a distance of 1340 light years from us and has AVM 1.70. Another example the line is
Bellatrix 245 1.64means that the star Bellatrix, which is again in the constellation Orion, is 245 light years away, and has AVM 1.64. Thus, Bellatrix is slightly brighter than Alnilam. The stars given in the file have their AVM between 0 and 3. Your programs should work correctly for any input file which is formatted like stars.txt, but it may have fewer or larger number of stars than your test file. However, you may assume all stars will have their AVM between 0 and 3.
What to SubmitFunctions to be submitted:
makeStarDict(filename) starDistance(dist1, dist2, starDict) starAVM(avm1, avm2, starDict) starMean(avm1, avm2, starDict)
Write all 4 functions in a Python text file named pa5.py, and submit your file using the Dropbox link. Submit only the functions; no test programs outside the functions are needed. Also, you may write and include in your pa5.py file as many helper functions as you want.
This programming assignment is graded out of 16 points, i.e., it has 6 points of extra credit. ←
Important: Add your full name and email address as a
comment in the first line of your file, such as:
cs8 web page