Question

def DMStoDD(degree, minutes, seconds): dd = abs(degree) + abs(minutes)/60 + abs(seconds)/3600 if degree > 0: return...

def DMStoDD(degree, minutes, seconds):
dd = abs(degree) + abs(minutes)/60 + abs(seconds)/3600

if degree > 0:
return dd
else:
return -dd

print(DMStoDD(-30, 30, 00))

In the script abovr, 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.

Homework Answers

Answer #1
def DMStoDD(degree, minutes, seconds):
    dd = abs(degree) + abs(minutes)/60 + abs(seconds)/3600

    if degree > 0:
        return dd
    else:
        return -dd


def DDtoDMS(dd):
    degree = int(abs(dd))
    minutes = int((abs(dd) - degree) * 60)
    seconds = int((((abs(dd) - degree) * 60) - minutes) * 60)
    if dd > 0:
        return tuple((degree, minutes, seconds))
    else:
        return tuple((-degree, minutes, seconds))


print(DMStoDD(-30, 30, 00))
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT