area = √s (s-a) (s-b) (s-c)

CIS 1051
Worksheet 2
Instructions: Calculate and print the area of a triangle given the length of each side using Heron's
1. Create a new Python project
2. Import the math library
3. Prompt the user to enter the length of the three sides of a rectangle as integer
4. Calculate the area of the triangle using the following formula:
area =
√ s (s-a) (s-b) (s-c)
where a,b, and c are the lengths of the sides, and s = ½ the perimeter
NOTE: To get the square root of a number, use the function sqrt() defined in the math
library. This function will take a positive number and return a number.
The area of the triangle with sides X, Y, and Z is A
5. Print a message to the screen similar to below:
Once written, test your program with the following values.
b=5 b=4 c=3
a = 56 b = 67 c = 12
a = 34 b = 94 c = 51
If you run into problems, use pdb to trace your program and determine why your program runs
incorrectly. Once you have found the reason, use assert statement(s) to ensure your program
only calculates valid results.
6. Ask the TA to check your work.
Random flashcards
State Flags

50 Cards Education

Countries of Europe

44 Cards Education

Art History

20 Cards StudyJedi

Sign language alphabet

26 Cards StudyJedi

Create flashcards