Python assignments: Difference between revisions

From AstroEdWiki
Jump to navigation Jump to search
Line 17: Line 17:
This catalog is similar to the NGC2000 catalog, in that it is in plain text, formatted by column, and has one star per line.  Each line contains specific information about the star, including cross-referenced catalog numbers, celestial coordinates, magnitudes and spectral types. Download the data files and explanatory pdf to your computer (right click in your browser, and save).
This catalog is similar to the NGC2000 catalog, in that it is in plain text, formatted by column, and has one star per line.  Each line contains specific information about the star, including cross-referenced catalog numbers, celestial coordinates, magnitudes and spectral types. Download the data files and explanatory pdf to your computer (right click in your browser, and save).


Use the [http://prancer.physics.louisville.edu/classes/650/python/examples ngc_reader.example] program we have discussed in class as a model, and write a program that reads and parses this file to find entries based on some aspect of the catalog.  The challenge for this assignment is to write a program that (ideally on the command line, but if necessary using the input inside the program) finds the entry of the star with the HD number 128620.  The program should print the right ascension, declination, magnitude, and spectral type for this star extracted from the catalog entry.
Use the [http://prancer.physics.louisville.edu/classes/650/python/examples ngc_reader.example] program we have discussed in class as a model, and write a program that reads and parses this file to find entries based on some aspect of the catalog.  The challenge for this assignment is to write a program that (ideally on the command line, but if necessary using the input inside the program) finds any  entries for the star with the HD number 128620.  The program should print the right ascension, declination, magnitude, and spectral type for the star extracted from the catalog entry.


Upload your finished working program to the [http://prancer.physics.louisville.edu/homework class  homework upload site].
Upload your finished working program to the [http://prancer.physics.louisville.edu/homework class  homework upload site].

Revision as of 10:48, 14 February 2013

This page contains assignments for our Research Methods - Programming with Python short course.

Homework 1: An assignment for very simple Python

Create a program called "gamma.py" that computes and prints the Gamma function of 3/2, and computes and prints the (square root of pi) divided by 2.

Run and see that the program returns the same values for these two quantities (within the floating point precision of your computer).

Submit your homework to the class upload site.


Homework 2: An assignment for solving problems with Python

On the class server we have downloaded a copy of the SKY2000 star catalog from the Vizier service. You will find it here, along with a pdf file that describes the catalog, and a short version of the first 100 lines from it for experimenting with your code.

This catalog is similar to the NGC2000 catalog, in that it is in plain text, formatted by column, and has one star per line. Each line contains specific information about the star, including cross-referenced catalog numbers, celestial coordinates, magnitudes and spectral types. Download the data files and explanatory pdf to your computer (right click in your browser, and save).

Use the ngc_reader.example program we have discussed in class as a model, and write a program that reads and parses this file to find entries based on some aspect of the catalog. The challenge for this assignment is to write a program that (ideally on the command line, but if necessary using the input inside the program) finds any entries for the star with the HD number 128620. The program should print the right ascension, declination, magnitude, and spectral type for the star extracted from the catalog entry.

Upload your finished working program to the class homework upload site.