Convert DD (decimal degrees) position to DMS (degrees, minutes, seconds).

##### Inputs:
`dd_lat` and `dd_lon` 2 strings representing the latitude and the longitude in degree -i.e. 2 floats included in [-90, 90] and [-180, 180]. Note that latitude 0 is north, longitude 0 is east.

##### Outputs:
A tuple of DMS latitudes formated as follows:
`DDD*mm'ss.sss"C`

With:
- `DDD`: degrees
- `mm`: minutes
- `ss.sss`: seconds rounded to 3 decimals
- `C`: first letter uppercase of the cardinal direction

##### ressources
about WGS 84 on [Wikipedia](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84)

Difficulty: EASY
Starter code: def convert_to_dms(dd_lat, dd_lon):
	

Solutions:
from math import floor

def convert(dd, direction):
	degrees = floor(dd)
	seconds = round(dd % 1 * 3600000)
	return '%03d*%02d\'%06.3f"%s' % (degrees, seconds // 60000, seconds % 60000 / 1000, direction)

def convert_to_dms(dd_lat, dd_lon):
	dd_lat = float(dd_lat)
	dd_lon = float(dd_lon)
	dms_lat = convert(abs(dd_lat), 'N' if dd_lat >= 0 else 'S')
	dms_lon = convert(abs(dd_lon), 'E' if dd_lon >= 0 else 'W')
	return (dms_lat, dms_lon)


def convert_to_dms(dd_lat, dd_lon):

	def convert(dd, c):
		d = abs(dd)
		m = d % 1 * 60
		s = m % 1 * 60
		return '{:03}*{:02}\'{:06.3f}"{}'.format(int(d), int(m), s, c[dd >= 0])
	return (convert(float(dd_lat), 'SN'), convert(float(dd_lon), 'WE'))


def convert_to_dms(*args):
	lst = []
	for (i, v) in enumerate(map(float, args)):
		av = abs(v)
		d = int(av)
		m = int((av - d) * 60)
		s = (av - d - m / 60) * 3600
		lst.append('{:03}*{:02}\'{:06.3f}"{}'.format(d, m, s, ['NS', 'EW'][i][v < 0]))
	return tuple(lst)


def W(Q, S):
	Q = float(Q)
	B = Q < 0
	Q = abs(Q)
	return '%03d*%02d\'%06.3f"%s' % (Q, Q % 1 * 60, 3600 * Q % 60, S[B])
convert_to_dms = lambda Q, S: (W(Q, 'NS'), W(S, 'EW'))


from math import floor

def deg_min_sec(coord):
	deg = floor(abs(float(coord)))
	min = floor((abs(float(coord)) - deg) * 60)
	sec = floor((abs(float(coord)) - deg - min / 60) * 3600)
	dec = str(round((abs(float(coord)) - deg - min / 60) * 3600 - sec, 3))[2:]
	return f'''{deg:03}*{min:02}'{sec:02}.{dec:<03}"'''

def convert_to_dms(dd_lat, dd_lon):
	lat_card = 'S' if '-' in str(dd_lat) else 'N'
	lon_card = 'W' if '-' in str(dd_lon) else 'E'
	return (f'{deg_min_sec(dd_lat)}{lat_card}', f'{deg_min_sec(dd_lon)}{lon_card}')


def convert_to_dms(dd_lat, dd_lon):

	def dd_to_dms(dd):
		h = int(dd)
		dd -= h
		m = int(dd * 60)
		dd -= m / 60
		s = round(dd * 3600, 3)
		return (h, m, s)
	(dd_lat, dd_lon) = map(float, (dd_lat, dd_lon))
	dms_lat = '{:03d}*{:02d}\'{:06.3f}"{:s}'.format(*dd_to_dms(abs(dd_lat)), 'NS'[dd_lat < 0])
	dms_lon = '{:03d}*{:02d}\'{:06.3f}"{:s}'.format(*dd_to_dms(abs(dd_lon)), 'EW'[dd_lon < 0])
	return (dms_lat, dms_lon)


def convert_to_dms(dd_lat, dd_lon):
	(dd_lat, dd_lon) = (float(dd_lat), float(dd_lon))
	if dd_lat >= 0:
		lat_dir = 'N'
	else:
		lat_dir = 'S'
		dd_lat *= -1
	lat_d = int(dd_lat)
	lat_m = (dd_lat - lat_d) * 60
	lat_s = round((lat_m - int(lat_m)) * 60, 3)
	lat_m = int(lat_m)
	dms_lat = '{:03d}*{:02d}\'{:06.3f}"{}'.format(lat_d, lat_m, lat_s, lat_dir)
	if dd_lon >= 0:
		lon_dir = 'E'
	else:
		lon_dir = 'W'
		dd_lon *= -1
	lon_d = int(dd_lon)
	lon_m = (dd_lon - lon_d) * 60
	lon_s = round((lon_m - int(lon_m)) * 60, 3)
	lon_m = int(lon_m)
	dms_lon = '{:03d}*{:02d}\'{:06.3f}"{}'.format(lon_d, lon_m, lon_s, lon_dir)
	return (dms_lat, dms_lon)


def dms(deg, dirs):
	v = abs(deg)
	return (int(v), int(60 * v % 60), 3600 * v % 60, dirs[deg < 0])

def convert_to_dms(dd_lat, dd_lon):
	return ('%03d*%02d\'%06.3f"%s' % dms(float(dd_lat), 'NS'), '%03d*%02d\'%06.3f"%s' % dms(float(dd_lon), 'EW'))


def f(l, d):
	a = abs(l)
	a1 = int(a)
	a = 60 * (a - a1)
	a2 = int(a)
	a = round(60 * (a - a2), 3)
	return '{:03}*{:02}\'{:06.3f}"{}'.format(a1, a2, a, d)

def convert_to_dms(lat, lon):
	a = float(lat)
	ns = ['S', 'N'][a >= 0]
	b = float(lon)
	we = ['W', 'E'][b >= 0]
	return (f(a, ns), f(b, we))


def gms(x):
	c = x >= 0
	x = abs(x)
	g = int(x)
	x = 60 * (x - g)
	m = int(x)
	x = 60 * (x - m)
	s = round(x, 3)
	return (g, m, s, c)

def formatea(g, m, s, c):
	g = '{:03d}'.format(g)
	m = '{:02d}'.format(m)
	s = '{:02.3f}'.format(s)
	s = '0' * (6 - len(s)) + s
	return f'''{g}*{m}'{s}"{c}'''

def convert_to_dms(*args):
	(dd_lat, dd_lon) = map(float, args)
	dms_lat = gms(dd_lat)
	dms_lon = gms(dd_lon)
	a = formatea(*dms_lat[:3], 'N' if dms_lat[3] else 'S')
	b = formatea(*dms_lon[:3], 'E' if dms_lon[3] else 'W')
	return (a, b)