Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Angles of a Triangle by jtarnowska
import math
def checkio(a, b, c):
x = a
y = b
z = c
error = [0, 0, 0]
try:
def angle (x, y, z):
return math.degrees(math.acos((z**2 - y**2 - x**2)/(-2.0 * x * y)))
angA = angle(x, y, z)
angB = angle(y, z, x)
angC = angle(z, x, y)
angles = []
angles.append(angA)
angles.append(angB)
angles.append(angC)
for i in range (len(angles)):
angles[i] = round(angles[i])
angles.sort()
for i in range (len(angles)):
if angles[i] == 0:
return(error)
print(angles)
return(angles)
except ValueError:
return(error)
#replace this for solution
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(4, 4, 4) == [60, 60, 60], "All sides are equal"
assert checkio(3, 4, 5) == [37, 53, 90], "Egyptian triangle"
assert checkio(2, 2, 5) == [0, 0, 0], "It's can not be a triangle"
Jan. 11, 2017