There are three requirements you must meet for full credit on each script:
The script must work as directed.
The script must not crash if given valid inputs.
You must include enough explanatory comments.
Although you may assume the inputs are in the proper format, you should think about
how the program could fail if user inputs are not valid. Future labs will ask you to trap
errors, and it isn’t too soon to start thinking about that. Although not required, you could
insert comments in your programs indicating where testing and trapping should take
place. Note that there are two kinds of errors a user might make: 1) invalid characters,
such as supplying input that can’t be converted to a number, 2) numbers that are
themselves invalid, such as latitudes greater than 90°.
For the following tasks, you can assume all coordinates are given in valid formats.
Write a function that converts an input latitude or longitude value in degrees, minutes,
and seconds (DMS; no decimals) into decimal degrees (DD). Directions:
The function should take a tuple containing three numbers representing degrees,
minutes and seconds and returns the corresponding decimal degree equivalent.
You can assume if the degree value is negative all 3 fields are negative. Thus “- 30 30 00” is -30.5 degrees, not -29.5 degrees.
Test your function with some known values before continue to task 2.
In the same script, add a function that converts from DD to DMS. Directions:
It should take one DD value and return a tuple containing 3 numbers representing D, M and S.
If DD is negative, the returned degree value should also be negative. The other two fields should be positive.
In the same script, add a main program that collects DD or DMS input from the user,
then convert it to the other form and report the converted value. Directions:
The main program needs to gather a string from the keyboard using raw_input() and detect whether it is DD or DMS (Hint: use the split function). Then pass proper DD or DMS values to the functions above to convert.
The DMS input is separated by comma and contains no space. The degree field could be negative to represent a negative value. (E.g. 43,4,23 or -43,4,23).
Contact us for this python assignment Solutions by Codersarts Specialist who can help you mentor and guide for such python programming assignments.
We also provide help in python assignment , homework, Coursework, final year mini - project, major project and development work help. contact us now at email@example.com and get in touch with our team of python experts