I have two programs I've been working on for my class but I keep getting different errors.
Write a boolean function called isTriangle that receives three numbers and returns true or false based on whether or not the
numbers are possible lengths of a triangle. If the sum of any two
sides is less than the third side, a triangle cannot be formed.
Here's what I have:
a = raw_input("Length of first side?")
b = raw_input("Length of second side?")
c = raw_input("Length of third side?")
def isTriangle(a, b, c):
if a + b < c:
elif a + c < b:
elif b + c < a:
The closest I got, I would get a false even though the numbers formed a triangle.
Write a function called heronsFomula that computes the area of a triangle given the length of the three sides. The formula is as
follows: sqrt(s(s-a)(s-b)(s-c)) ,where s is half the perimeter and a, b, and c are the lengths of the sides.
What I put in:
def sides (firstSide, secondSide, thirdSide):
s = (firstSide + secondSide + thirdSide)/2.0
firstSide = raw_input ("Length of first side? ")
firstSide = float (firstSide)
secondSide = raw_input ("Length of second side? ")
secondSide = float (secondSide)
thirdSide = raw_input ("Length of third side? ")
thirdSide = float (thirdSide)
sides (firstSide, secondSide, thirdSide)
I haven't put the formula part in yet because I haven't successfully calculated s.