$29
Learning objectives:
Develop a Python program that uses the graphics package.
Practice writing functions
Assignment:
The text has a program, triangle.py. A modified version that does not use coordinates is available on Oaks.
Modify this program so that it uses a function, makeTriangle(p1, p2, p3), to create the triangle. That is, the three points are passed to the function, and it returns a Triangle object. Make the colors whatever you like. Draw the triangle that the function returns in main().
Write a function, distance(p1, p2), that is passed two points and that returns the Euclidean distance between the points.
Write functions, perimeter(tri) and area(tri), to compute the perimeter and area of the triangle. Each of these must have a single parameter, the Triangle object. Look at the text, section 4.8.2 (Polygon Methods), to see how to get the points of the triangle. Each of these must use the distance(p1, p2) function.
Display the perimeter and area in the graphics window, preferably near the bottom.
Submission:
Submit triangle.py to your class account.
Policies:
The policies on OAKS are applicable for this and all assignments.