Reputation: 1
https://i.sstatic.net/xWSIc.png when I run this code:
import turtle
import math
pi = math.pi
def triangle(a,b,c):
# law of cosines, where ac = angle c
ac = math.acos(a**2 + b**2 - c**2/(2*a*b)*180/pi
# law of sines
ab = math.asin(math.sin(ac)/c*b)*180/pi
# Angle sum theorem
aa = 180 - (ab + ac)
lengths = [a,b,c]
angles = [ac,aa,ab]
for n in range 3:
turtle.forward(lengths[n])
turtle.left(180-angles[n])
triangle(3,4,5)'
Sublimetext 3 returns:
File "C:\Users\chul\Documents\GitHub\One-Python-Project-Per-Day\April\18 triangle.py", line 10
ab = math.asin(math.sin(ac)/c*b)*180/pi
^
SyntaxError: invalid syntax
Can anybody explain what is going on?
Upvotes: 0
Views: 451
Reputation: 35
Your
ac = math.acos(a**2 + b**2 - c**2/(2*a*b)*180/pi
is missing a end bracket:
ac = math.acos(a**2 + b**2 - c**2/(2*a*b)*180/pi)
Upvotes: 1