Useful Programming Functions The following are functions that will be useful for completing the lat-long grid programming project: len(string) : returns the length (no. of characters) in a string variable or expression float(string): returns the floating point equivalent of the string int(float number): returns the integer portion of a floating point number round(float number): returns the integer result of rounding a floating point number abs(number): returns the absolute value of the number (floating point or integer) str(number): returns the string equivalent of a number (floating point or integer) sys.argv[1]: returns the 1st parameter string on the command line Programming Outline Initialize constants (output file name, length of longitude/latitude strings, end-of-line character, output file delimiter). Retrieve and store command line parameters (or prompt interactively for string): Alex City AL 1:24k: “c:/temp/grid.txt -0860000 +325230 -0855230 +330000 000230 000230” Montgomery AL 1:100k: “c:/temp/grid.txt -0870000 +320000 -0860000 +323000 000730 000730” Montgomery AL 1:250k: “c:/temp/grid.txt -0880000 +320000 -0860000 +330000 001500 001500” Note that in the above examples the input string must be enclosed in quotes if you prompt interactively with an “input” statement. Check latitude/Longitude strings for proper length and whether they have a “-“ sign (do this with a function because it is repetitive). Convert longitude/latitude values to decimal degree values (use functions). Open text file for output. Calculate number of rows and columns for calibration marks. Initialize counters for while loop. Construct a double while-loop to loop through all columns and rows. Calculate the decimal degree value of the longitude/latitude coordinate appropriate for the current row and column position.
Useful Programming Functions The following are functions that will be useful for completing the lat-long grid programming project: len(string) : returns the length (no. of characters) in a string variable or expression float(string): returns the floating point equivalent of the string int(float number): returns the integer portion of a floating point number round(float number): returns the integer result of rounding a floating point number abs(number): returns the absolute value of the number (floating point or integer) str(number): returns the string equivalent of a number (floating point or integer) sys.argv[1]: returns the 1st parameter string on the command line Programming Outline Initialize constants (output file name, length of longitude/latitude strings, end-of-line character, output file delimiter). Retrieve and store command line parameters (or prompt interactively for string): Alex City AL 1:24k: “c:/temp/grid.txt -0860000 +325230 -0855230 +330000 000230 000230” Montgomery AL 1:100k: “c:/temp/grid.txt -0870000 +320000 -0860000 +323000 000730 000730” Montgomery AL 1:250k: “c:/temp/grid.txt -0880000 +320000 -0860000 +330000 001500 001500” Note that in the above examples the input string must be enclosed in quotes if you prompt interactively with an “input” statement. Check latitude/Longitude strings for proper length and whether they have a “-“ sign (do this with a function because it is repetitive). Convert longitude/latitude values to decimal degree values (use functions). Open text file for output. Calculate number of rows and columns for calibration marks. Initialize counters for while loop. Construct a double while-loop to loop through all columns and rows. Calculate the decimal degree value of the longitude/latitude coordinate appropriate for the current row and column position.
FinalExamProgrammingProject.docx