Write a simple function that takes polar coordinates (an angle in degrees and a radius) and returns the equivalent cartesian coordinates (rouded to 10 places).

```
For example:

coordinates(90,1)
=> (0.0, 1.0)

coordinates(45, 1)
=> (0.7071067812, 0.7071067812)
```

Source: codewars | Difficulty: EASY
Tags: Geometry

Mathematics

Starter code: def coordinates(degrees, radius):
	

Solutions:
from math import cos, sin, radians

def coordinates(deg, r, precision=10):
	(x, y) = (r * cos(radians(deg)), r * sin(radians(deg)))
	return (round(x, precision), round(y, precision))


from math import cos, sin, radians

def coordinates(d, r):
	convert = lambda x: round(r * x(radians(d)), 10)
	return (convert(cos), convert(sin))


from math import cos, radians, sin

def coordinates(th, r):
	return tuple((round(r * f(radians(th)), 10) for f in (cos, sin)))


from math import cos, sin, radians

def coordinates(d, r):
	return (round(r * cos(radians(d)), 10), round(r * sin(radians(d)), 10))


import math

def coordinates(degrees, radius):
	theta = math.radians(degrees)
	x = math.cos(theta) * radius
	y = math.sin(theta) * radius
	return (round(x, 10), round(y, 10))


from math import sin, cos, radians

def coordinates(deg, r):
	theta = radians(deg)
	return tuple((round(r * f(theta), 10) for f in (cos, sin)))


def coordinates(d, r):
	c = r * 1j ** (d / 90)
	return (round(c.real, 10), round(c.imag, 10))


from math import radians, sin, cos

def coordinates(degrees, radius):
	angle = radians(degrees)
	return tuple((round(f(angle) * radius, 10) for f in (cos, sin)))


import math

def coordinates(degrees, radius):
	if degrees != 0:
		degrees = math.pi / (180 / degrees)
	else:
		degrees = 0
	return (round(radius * math.cos(degrees), 10), round(radius * math.sin(degrees), 10))


from math import radians, sin, cos

def coordinates(degrees, radius):
	return (round(radius * cos(radians(degrees)), 10), round(radius * sin(radians(degrees)), 10))