Due Date: Monday February 15 by the end of the lab session

Submit the program you write with the Canvas link on the assignment.

__Educational goals of this lab - verify that every student can__

- work with their team
- write an algebraic formula in correct Python syntax
- use input and output statements correctly
- import a library
- call a math function
- use test cases to test a program

**Description of the problem:**

Points on the Cartesian plane are specified by x, y pairs, like (x1, y1) and (x2, y2). The distance between two points is given by the formula .

The points can describe different shapes. Given 3 points, you can describe a triangle. Yes, there are exceptions which we won't worry about now.

The sum of the length of the three sides of the triangle is called
the perimeter.

Above is a formula for the area of a triangle (ANY triangle).
It is called "Heron's formula" (also "Hero's formula"). s is defined
as the perimeter divided by 2 (called a semi-perimeter).
a, b and c are the lengths of the sides of the triangle.

Your job is to allow the user to enter the coordinates of 3 points and then calculate the perimeter and area of the triangle given by the 3 points. You can assume the coordinates are integers.

(24 points) **Team Problem #1: ** Test Cases (work these out FIRST!, before class if possible)

Create a multi-line comment at the bottom of your program file which contains the answers that go in the blanks below. It should be the expected output from the program described below, the payment, given the inputs in the case. Use a calculator as needed. Here is a online calculator that you can use. You get 12 points for calculating them, 12 points when your program runs and gives the correct answers. You do NOT want to copy the output of the program here and paste it in! You are doing these BEFORE the program is written!

Description | Inputs x1, y1, x2, y2, x3, y3 | Expected Outputs Perimeter Area |
---|---|---|

Normal cases | ||

Normal case with positive coordinates | 1,1,3,4,5,17 | ____A.____ |

Normal case with negative ints for some inputs | -4,3,2,1,0,4 | ____B.____ |

Triangle with large sides | 100000,5, 2000,4,3,9 | ____C.____ |

Two sides are length 1 | 1,1, 2,1,1,2 | ____D.____ |

All coordinates are the same | 1,1,1,1,1,1 | ____E.____ |

All coordinates are on the same straight line | 1,1,2,2,3,3 | ____F.____ |

Remember these answers, A-F, are in a multi-line comment at the bottom of the team lab3.py file.

(15 points) **Team Problem #2:** Design

Paste this design into your lab3.py file and complete the last 2 steps.

#1. Print title #2. Get 6 inputs from user (x,y,x,y,x,y) #3. Calculate the distances between each pair of points (lengths of sides) COMPLETE THIS

(53 points) **Team Problem #3: ** Implementation

- Write a program that use the design in problem #3 to tell given 3 points' coordinates, what the perimeter and area of the triangle are.
- You MUST have a main function definition (def main():) and a call to main (main()) at the bottom.
- You must use the sqrt function from the math library. The import statement goes BEFORE the def main(): line.
- Put spaces around your operators - makes them MUCH easier to read! Both the assignment operator (=) and the math operators.
- The design should be interlaced with the code, NOT in the prolog!
- Variable names MUST have more than one character. The reason the formula is given with single letters is that mathematicians have to write the formula by hand and the single letters makes it easier. You are typing your identifiers, so you have time to make them a bit longer. Don't use "s", use "semiP".
- There are 6 integers input, which represent 3 x,y pairs. You should input them in the order given in the sample runs
- Show results with 3 decimal places. Match the sample runs as closely as possible.
- Test case 1 (one with easy numbers, so easy to see it is correct)
Triangle Calculator Enter x1: 0 Enter y1: 0 Enter x2: 1 Enter y2: 0 Enter x3: 0 Enter y3: 1 The perimeter of the triangle is 3.414 The area of the triangle is 0.500

- Test case 2
Triangle Calculator Enter x1: 99 Enter y1: 400 Enter x2: 33 Enter y2: 700 Enter x3: 1 Enter y3: 5 The perimeter of the triangle is 1409.886 The area of the triangle is 27735.000

- Make sure to run your test cases from above to see that you are getting the right answers.
- Make sure that all members of the team
**understand**the team result. - Submit with the Canvas link.

Make sure you save your programs somewhere as a backup to the copy on Canvas! Teams forget to submit sometimes!