Write a Python program that prompts the user for 3 inputs re

Write a Python program that prompts the user for 3 inputs representing the lengths of sides of a Triangle. Add the code that will calculate the area of that Triangle statement Area of and print the For Triangle with sides a, b, c = area For example: (Area of Triangle = squareroot s(s + a)(s + b)(s + c), where s = (a + b + c)/2 where a, b, c are length of sides). You can use the int function to clean up your output if you choose. Do not forget to include a screenshot of your Python window

Solution

python code:

print \"Please enter length of side 1\"
a = float(raw_input().strip())
print \"Please enter length of side 2\"
b = float(raw_input().strip())
print \"Please enter length of side 3\"
c = float(raw_input().strip())

s = float(a+b+c)/2.0
print s
area = (s*(s-a)*(s-b)*(s-c))**0.5
print \"Area of triangle with sides (\",a,b,c,\") is \", int(area)

Sample Output:

akash@akash-SVE15116ENB:~/Desktop/chegg/triangl ara$ python code.py
Please enter length of side 1
6
Please enter length of side 2
8
Please enter length of side 3
9
11.5
Area of triangle with sides ( 6.0 8.0 9.0 ) is 23
akash@akash-SVE15116ENB:~/Desktop/chegg/triangl ara$ python code.py
Please enter length of side 1
3
Please enter length of side 2
4
Please enter length of side 3
5
6.0
Area of triangle with sides ( 3.0 4.0 5.0 ) is 6

 Write a Python program that prompts the user for 3 inputs representing the lengths of sides of a Triangle. Add the code that will calculate the area of that Tr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site