Find the total sum of internal angles (in degrees) in an n-sided simple polygon. N will be greater than 2.

Difficulty: EASY
Tags: Geometry

Fundamentals

Starter code:
def angle(n):
	

Solutions:
def angle(n):
	return 180 * (n - 2)


angle = lambda n: (n - 2) * 180


def angle(n):
	if n > 2:
		return 180 * (n - 2)
print(angle(5))


def angle(n):
	return (n + ~1) * 180


def angle(n):
	if n > 2:
		return (n - 2) * 180
	else:
		return 'Error'


def angle(n):
	if n == 3:
		return 180
	elif n == 4:
		return 360
	else:
		x = 180 * (n - 2)
		return x


def angle(n):
	counter = 3
	if n == 3:
		angle = n * 60
	else:
		n > 3
		angle = (n - 2) * 180
	counter += 1
	return angle


def angle(n):
	ang = n * 2
	angg = ang - 4
	sumang = angg * 90
	return sumang


def angle(n):
	if n > 2:
		return abs(n - 2) * 180


def angle(n):
	while n > 2:
		degrees = n * 180 - 360
		return degrees


def angle(n):
	return 180 * (n - 2) if n > 2 else None


import math

def angle(n):
	return 180 * n - 360


def angle(ip):
	return (ip - 2) * 180


def angle(n):
	sum = (2 * n - 4) * 90
	return sum


def angle(n):
	if n > 2:
		return (n - 2) * 180
	else:
		return 'not a simple polygon'


def angle(n):
	if n < 2:
		return 0
	else:
		return (n - 2) * 180


def angle(n):
	polygon = (n - 2) * 180
	if n < 3:
		return 'not a polygon'
	else:
		return polygon


def angle(n):
	ans = 1440
	ans = (n - 2) * 180
	return ans


def angle(n):
	return 360 * (n - 2) / 2


def angle(n):
	if n < 3:
		return 0
	return (n - 2) * 180
n = 5
print(angle(n))


def angle(n):
	degree = (n - 2) * (180 / n) * n
	return round(degree)


def angle(n):
	if n < 3:
		return 'LOL'
	elif n == 3:
		return 180
	else:
		return 180 * (n - 2)


def angle(n):
	if n == 3:
		s = 180
	if n > 3:
		s = 180 + (n - 3) * 180
	return s


def angle(n):
	if n == 3:
		return 90 + 45 + 45
	return (n - 2) * 180


def angle(n):
	res = 0
	for i in range(3, n + 1):
		res = res + 180
	return res


def angle(n):
	if n > 2:
		s = (n - 2) * 180
	return s


def angle(n):
	sum_angles = 180
	if n > 2:
		return sum_angles * (n - 2)
	return sum_angles


def angle(n):
	if not n >= 3:
		return
	sum = 180
	for _ in range(n - 3):
		sum = sum + 180
	return sum


def angle(n):
	result = (n - 2) * 180 / n
	return round(result * n)


def angle(n):
	t = 0
	if n > 3:
		return (n - 3 + 1) * 180
	elif n == 3:
		return 180


import math

def angle(n):
	return 180 * (n - 2)


def angle(N):
	return 180 * (N - 2)


def angle(n):
	return int((180 - 360 / n) * n + 0.5)


def angle(n):
	for multiply in range(n):
		result = 180 * (multiply - 1)
	return result


def angle(n):
	triangles = n - 2
	total_degrees = 180 * triangles
	return total_degrees


def angle(n):
	k = (n - 2) * 180
	if n > 2:
		return k
	else:
		return N / A


def angle(n):
	return 180 if n == 3 else 180 * (n - 2)


def angle(n):
	x = 0
	for i in range(2, n):
		x += 180
	return x


def angle(n):
	print(n)
	result = (n - 2) * 180
	print(result)
	return result


def angle(n):
	if n == 3:
		return 180
	else:
		return angle(n - 1) + 180


def angle(number):
	return 180 * (number - 2)


def angle(n):
	sum_angle = (n - 2) * 180
	return sum_angle
n = 3
print(angle(n))


def angle(n):
	if n <= 2:
		raise ValueError
	else:
		return 180 * (int(n) - 2)


def angle(n):
	return (n - 2) * 180 if n > 2 else 'error'


def angle(n):
	if n > 2:
		return (n - 2) * 180
	else:
		return -1


def angle(n):
	s = 180
	p = 0
	if n == 3:
		return s
	if n > 3:
		for i in range(3, n + 1):
			p = p + s
	return p


def angle(n):
	return round(180 * n - 360)


def angle(n):
	if n > 2:
		return int((180 - 360 / n) * n + 0.5)
	else:
		print('error')
		return ''


import unittest

def angle(n):
	return 180 * (n - 2)

class TestAngle(unittest.TestCase):

	def test_should_return_180_when_given_n_is_3(self):
		self.assertEqual(angle(3), 180)

	def test_should_return_360_when_given_n_is_4(self):
		self.assertEqual(angle(4), 360)

	def test_should_return_540_when_given_n_is_5(self):
		self.assertEqual(angle(5), 540)


def angle(n):
	x = (n - 2) * 180
	return x
print(angle(6))


def angle(n):
	if n == 3:
		a = 180
	elif n >= 4:
		a = 180 * (n - 2)
	return a


def angle(n):
	if n > 2:
		return (n - 2) * 180
	else:
		return none


def angle(n):
	if n < 3:
		return 0
	return (n - 2) * 180


def angle(n):
	if n < 3:
		print('Has to be a shape, try again')
	elif n == 3:
		return 180
	elif n > 3:
		n = (n - 4) * 180 + 360
	return n


def angle(n):
	if n > 2:
		sum = (n - 2) * 180
	return sum


def angle(n):
	triangleNum = n - 2
	totalInternalAngles = triangleNum * 180
	return totalInternalAngles


def angle(num_sides):
	return (num_sides - 2) * 180


angle = lambda n: round(n * (180 - 360 / n))


angle = lambda x: 180 * (x - 2)


def angle(n):
	result = 180
	if n > 3:
		for i in range(n - 3):
			result += 180
	return result


def angle(n):
	if n > 2:
		ans = 0
		for i in range(n - 2):
			ans = ans + 180
		return ans


def angle(n):
	if n < 3:
		print('no polygon')
	if n >= 3:
		return (n - 2) * 180