Cameron Burst
Cameron Burst

Reputation: 11

Attempting to solve a SAS triangle- getting wrong output using math.cos

import math
a = 5
b = 7
C = 49

c = (a**2)+(b**2)-(2*a*b*(math.cos(C)))
gc = math.sqrt(c)

print(gc)

It outputs 7.27726060671 when it should output something like 5.3. Any help would be very appreciated.

-Cam

Upvotes: 0

Views: 213

Answers (1)

pault
pault

Reputation: 43534

You need to convert to radians first:

Try:

c = (a**2)+(b**2)-(2*a*b*(math.cos(math.radians(C))))
print(math.sqrt(c))
#5.29866662196

Upvotes: 2

Related Questions