Python | Degrees, Minutes and Seconds.. (and decimal degrees........)

/ 30 Jul 2013 /
I REALLY DO NOT KNOW WHY I MADE THIS, IT JUST MAKES SOLVING THE PROBLEMS HARDER, BUT, I DID, FOR BOTH (DMS) AND (DD), GOD HELP ME.




 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
while 1:
    def dd():
        D = int(input('Degrees:  '))
        M = int(input('Minutes:  '))
        S = int(input('Seconds:  '))
        dd = D + M / 60 + S / 3600
        print(dd)
    
    def dms():
        DD = int(input('Enter the dd (no decimal):  '))
        DDd = float(input('Enter the dd DECIMAL:  '))
        D = DD
        M = DDd * 60
        mM = str(M)
        Mm = mM.find('.')
        print('The decimal of M is', mM[Mm:])
        SS = float(input('Enter decimal of M:  '))
        S = SS * 60
        sS = str(S)
        print()
        print()
        print('__________________________________________________')
        print('The Degrees, Minutes and seconds of ', DD + DDd,'°', 'is :')
        print('______________')
        print(D, '°', mM[0:2], '\'', sS[0:2], '\'\'')
        print('______________')
        print()
        print()

    choice = input('''1) Get Decimal Degree
2) Get Degrees, Minutes, Seconds
Choose your converter:  ''')
    if choice == '1':
        dd()
    elif choice == '2':
        dms()
    else:
        pass
 
Copyright © 2010 M(ath)+me, All rights reserved