[Tutor] Help!

Carpenter, Steven Steven.Carpenter at oakland.k12.mi.us
Fri Jan 18 13:56:53 CET 2013


To Whom it May Concern,
I'm trying to get this code working. Here's my question:
Consider a triangle with sides of length 3, 7, and 9. The law of cosines states that given three sides of a triangle (a, b, and c) and angle C between sides a and b: Write Python code to calculate the three angles in the triangle.
Here's my code:
# Calculate the angles in a triangle
# Imports the Math data
import math
# Sets up the different angles with corresponding letters
# The first angle is a
a = 3
# The second angle is b
b = 7
# The third angle is c
c = 9
# Calculates angle "C"
print(math.acos(((a**2)+(b**2)-(c**2))/(2(a*b))))
Here's my output:
Traceback (most recent call last):
  File "E:\Programming\Problem4.py", line 12, in <module>
    print(math.acos(((a**2)+(b**2)-(c**2))/(2(a*b))))
TypeError: 'int' object is not callable

Steven Carpenter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130118/8c11b50d/attachment.html>


More information about the Tutor mailing list